Slim speech-android to Android-only after speech-core PRs #19/#20#28
Merged
Conversation
…h-core speech-core PRs #19 and #20 lifted all the model wrappers, audio utilities, and Linux examples out of this repo. This PR finishes the migration by deleting the now-duplicated source and slimming the native side to a single ~250-line JNI bridge. Net change: 51 files, +717 / -7412. Bumped: - speech-core submodule pointer: 679869d → ba75579 (PR #19 + #20 merged) Deleted (now in speech-core): - sdk/src/main/cpp/audio/ — fft, mel, stft (live at speech_core::audio) - sdk/src/main/cpp/util/ — json.h - sdk/src/main/cpp/models/ — silero_vad, parakeet_stt, kokoro_tts + phonemizer + multilingual, deepfilter, onnx_engine, inference_engine, onnx_backend, soc_detect - linux/ — moved verbatim to speech-core/examples/linux/ (libspeech.so, demo, CLIs, integration test) Rewrote: - sdk/src/main/cpp/jni_bridge.cpp (388 → 269 lines) — the model wrappers in speech_core::* directly implement VADInterface / STTInterface / TTSInterface / EnhancerInterface, so the 100+ lines of C-vtable adapter boilerplate (vad_process_chunk, stt_transcribe, tts_synthesize, etc.) that wrapped each model class into sc_*_vtable_t structs are gone. The bridge now constructs speech_core::SileroVad / ParakeetStt / KokoroTts and hands references to speech_core::VoicePipeline. - sdk/src/main/cpp/CMakeLists.txt — replaced the manual list of speech-core source files with add_subdirectory(${SPEECH_CORE_DIR}) using SPEECH_CORE_WITH_ONNX=ON. Link speech_android against speech_core_models. Compatibility: - Kotlin contract unchanged. NativeBridge.onEvent still receives the same int event-type values (0..11). The new speech_core::EventType enum has ResponseDone and ResponseAudioDelta swapped relative to the old C ABI (sc_event_t.type) — added to_kotlin_event() to map explicitly so the Kotlin side keeps working without any change. - Public Kotlin API (SpeechPipeline, SpeechConfig, SpeechEvent) untouched. Docs: - README.md rewritten as Android-only (Linux/Yocto/QNN sections moved to a one-line cross-link pointing at speech-core/examples/linux). - All 9 README translations updated to mirror the new structure (zh, ja, ko, es, de, fr, hi, pt, ru) with existing high-quality translations preserved where the underlying English text is unchanged. - AGENTS.md rewritten — Android-only scope, points contributors at speech-core for any C++ / model / Linux changes. - .gitignore drops the linux/tests/models/ and /ort-linux/ entries that are no longer relevant. - setup.sh trimmed to just the Android ORT download + submodule init (it was previously rewriting the .gitignore on every invocation). Verified locally: - ./gradlew :sdk:externalNativeBuildDebug — BUILD SUCCESSFUL, 5.6 MB libspeech_android.so produced for arm64-v8a, links libonnxruntime.so and libc++_shared.so cleanly. - ./gradlew :sdk:assembleDebug :sdk:test — BUILD SUCCESSFUL, 77 tasks. Next: connectedAndroidTest needs to run on an emulator (downloads 1.2 GB of models on first run); will run that in CI rather than locally.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
speech-core PRs #19 and #20 lifted all the model wrappers, audio utilities, and Linux examples out of this repo into speech-core. This PR finishes the migration: delete the now-duplicated source, rewrite the JNI bridge without C-vtable adapter boilerplate, and slim the native side to a single ~250-line file.
51 files changed, +717 / −7,412.
What's deleted
sdk/src/main/cpp/audio/{fft,mel,stft}.{h,cpp}speech_core::audio::*in speech-coresdk/src/main/cpp/util/json.hspeech_core/util/json.hsdk/src/main/cpp/models/*.{h,cpp}(16 files)speech_core::SileroVad/ParakeetStt/KokoroTts/DeepFilterEnhancer+OnnxEnginelinux/(12 files)speech-core/examples/linux/What's rewritten
sdk/src/main/cpp/jni_bridge.cpp(388 → 269 lines): the model wrappers inspeech_core::*directly implementVADInterface/STTInterface/TTSInterface/EnhancerInterface, so 100+ lines of C-vtable adapter boilerplate (vad_process_chunk,stt_transcribe,tts_synthesize, …) are gone. The bridge constructs the model objects and hands references tospeech_core::VoicePipeline. Same pattern that shrunklinux/src/speech.cppfrom 259 → 184 lines in speech-core PR #20.sdk/src/main/cpp/CMakeLists.txt: replaced the manual speech-core source list withadd_subdirectory(${SPEECH_CORE_DIR})+SPEECH_CORE_WITH_ONNX=ON. Linkspeech_androidagainstspeech_core_models.Kotlin contract preserved
NativeBridge.onEventstill receives the sameintevent-type values (0..11). The newspeech_core::EventTypeenum hasResponseDoneandResponseAudioDeltaswapped relative to the old C ABI (sc_event_t.type), so the JNI bridge has a smallto_kotlin_event()mapping function to keep the Kotlin side working without any change. Public Kotlin API (SpeechPipeline,SpeechConfig,SpeechEvent) untouched.Docs
README.mdrewritten as Android-only — Linux/Yocto/QNN sections collapsed into a one-line cross-link tospeech-core/examples/linux.AGENTS.mdrewritten — Android-only scope, contributors directed at speech-core for any C++/model/Linux work..gitignoredropslinux/tests/models/and/ort-linux/entries.setup.shtrimmed (it was rewriting.gitignoreon every invocation).Submodule bump
speech-coresubmodule pointer:679869d→ba75579(PR Add Android RecognitionService for system-wide voice input #19 + Bug: crash on SM-S916B #20 merged on speech-core main).Verified locally
./gradlew :sdk:externalNativeBuildDebug→ BUILD SUCCESSFUL, produces 5.6 MBlibspeech_android.so(arm64-v8a) linkinglibonnxruntime.soandlibc++_shared.socleanly../gradlew :sdk:assembleDebug :sdk:test→ BUILD SUCCESSFUL, 77 tasks executed.Test plan
externalNativeBuildDebug) — green:sdk:test) — greenconnectedAndroidTeston emulator (needs ~1.2 GB model download on first run) — will run in CI