Skip to content

Slim speech-android to Android-only after speech-core PRs #19/#20#28

Merged
ivan-digital merged 1 commit into
mainfrom
feat/android-only
May 13, 2026
Merged

Slim speech-android to Android-only after speech-core PRs #19/#20#28
ivan-digital merged 1 commit into
mainfrom
feat/android-only

Conversation

@ivan-digital
Copy link
Copy Markdown
Contributor

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

Path Replaced by
sdk/src/main/cpp/audio/{fft,mel,stft}.{h,cpp} speech_core::audio::* in speech-core
sdk/src/main/cpp/util/json.h speech_core/util/json.h
sdk/src/main/cpp/models/*.{h,cpp} (16 files) speech_core::SileroVad / ParakeetStt / KokoroTts / DeepFilterEnhancer + OnnxEngine
linux/ (12 files) speech-core/examples/linux/

What's rewritten

sdk/src/main/cpp/jni_bridge.cpp (388 → 269 lines): the model wrappers in speech_core::* directly implement VADInterface / 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 to speech_core::VoicePipeline. Same pattern that shrunk linux/src/speech.cpp from 259 → 184 lines in speech-core PR #20.

sdk/src/main/cpp/CMakeLists.txt: replaced the manual speech-core source list with add_subdirectory(${SPEECH_CORE_DIR}) + SPEECH_CORE_WITH_ONNX=ON. Link speech_android against speech_core_models.

Kotlin contract preserved

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), so the JNI bridge has a small to_kotlin_event() mapping function to keep the Kotlin side working without any change. Public Kotlin API (SpeechPipeline, SpeechConfig, SpeechEvent) untouched.

Docs

  • README.md rewritten as Android-only — Linux/Yocto/QNN sections collapsed into a one-line cross-link to speech-core/examples/linux.
  • All 9 README translations (zh, ja, ko, es, de, fr, hi, pt, ru) updated in parallel by subagents, preserving high-quality existing translations.
  • AGENTS.md rewritten — Android-only scope, contributors directed at speech-core for any C++/model/Linux work.
  • .gitignore drops linux/tests/models/ and /ort-linux/ entries.
  • setup.sh trimmed (it was rewriting .gitignore on every invocation).

Submodule bump

Verified locally

  • ./gradlew :sdk:externalNativeBuildDebug → BUILD SUCCESSFUL, produces 5.6 MB libspeech_android.so (arm64-v8a) linking libonnxruntime.so and libc++_shared.so cleanly.
  • ./gradlew :sdk:assembleDebug :sdk:test → BUILD SUCCESSFUL, 77 tasks executed.

Test plan

  • Native build (externalNativeBuildDebug) — green
  • SDK assembleDebug — green
  • Unit tests (:sdk:test) — green
  • connectedAndroidTest on emulator (needs ~1.2 GB model download on first run) — will run in CI
  • Demo app smoke test on real device — manual pre-release check

…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.
@ivan-digital ivan-digital merged commit 6b0c70b into main May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant