Skip to content

feat(voice): support mobile linking and cancellation - #3361

Open
johnmatthewtennant wants to merge 3 commits into
mainfrom
jtennant/buzz-voice-mobile-linking-april
Open

feat(voice): support mobile linking and cancellation#3361
johnmatthewtennant wants to merge 3 commits into
mainfrom
jtennant/buzz-voice-mobile-linking-april

Conversation

@johnmatthewtennant

@johnmatthewtennant johnmatthewtennant commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Context

Native mobile clients need to link buzz-voice against platform-specific sherpa-onnx libraries and cancel Pocket TTS before a complete utterance has been synthesized. The existing dependency and buffered synthesis API do not provide those contracts.

Summary

This PR lets consumers select static linking on iOS or shared linking on Android, provide verified official libraries, and interrupt Pocket synthesis through a monotonic callback. Consumers remain responsible for downloading, verifying, and packaging native artifacts.

No model or native binary is bundled.

Changes

  • Keeps static linking as the default and adds an explicit shared-link feature across buzz-voice, sherpa-onnx, and sherpa-onnx-sys.
  • Adds interruptible Pocket synthesis while preserving the buffered synth_chunk API.
  • Polls cancellation during latent generation, reports monotonic progress, rejects same-engine callback re-entry, and contains callback panics.
  • Carries the upstream sherpa-onnx-sys 1.13.4 metadata, bindings, and license with a mobile-aware linker contract.
  • Fails closed unless mobile callers provide a normalized, verified SHERPA_ONNX_LIB_DIR.
  • Documents the consumer-owned boundary for archive verification, target selection, Cargo patching, and Xcode or Gradle packaging.

Related issue

None found.

Testing

A disposable external consumer compiled the callback API with only the intended target feature. The iOS simulator produced a static library from normalized official XCFramework slices. Android completed an arm64 shared-library cross-target check against the official ABI directory. cargo package verified the standalone buzz-voice package.

Berd Mobile #12 is the current external consumer. Buzz Mobile can use the same contract with its own native adapter and packaging.

Screenshots

N/A. This is a Rust API and native-linking change with no UI.

Reviewer-reproducible examples

Exercise cancellation before PCM is available and verify callback panics are contained:

cargo test -p buzz-voice --lib callback

Output excerpt:

running 2 tests
test pocket::tests::callback_can_cancel_before_pcm_is_available ... ok
test pocket::tests::callback_panic_is_reported_without_unwinding ... ok
test result: ok. 2 passed; 0 failed

Confirm the target-specific feature graphs:

cargo tree --locked -p buzz-voice --target aarch64-apple-ios-sim \
  -e features -i sherpa-onnx-sys

cargo tree --locked -p buzz-voice --target aarch64-linux-android \
  --no-default-features --features shared \
  -e features -i sherpa-onnx-sys

With normalized official sherpa-onnx 1.13.4 libraries prepared as documented in crates/sherpa-onnx-sys/README.md, compile each mobile mode:

SHERPA_ONNX_LIB_DIR=/absolute/path/to/ios-normalized \
  IPHONEOS_DEPLOYMENT_TARGET=15.1 \
  cargo build -p buzz-voice --target aarch64-apple-ios-sim \
  --no-default-features --features static

SHERPA_ONNX_LIB_DIR=/absolute/path/to/android/arm64-v8a \
  cargo check -p buzz-voice --target aarch64-linux-android \
  --no-default-features --features shared

@johnmatthewtennant
johnmatthewtennant changed the base branch from jtennant/buzz-voice-extraction-april to jt/buzz-voice-refactor July 28, 2026 19:19
@johnmatthewtennant
johnmatthewtennant force-pushed the jtennant/buzz-voice-mobile-linking-april branch from df2b7d9 to 5514cb2 Compare July 28, 2026 21:00
@johnmatthewtennant
johnmatthewtennant force-pushed the jtennant/buzz-voice-mobile-linking-april branch from 5514cb2 to 19ea0ad Compare July 28, 2026 21:43
@johnmatthewtennant
johnmatthewtennant force-pushed the jtennant/buzz-voice-mobile-linking-april branch from 19ea0ad to b1c899f Compare July 29, 2026 00:16
johnmatthewtennant and others added 3 commits July 31, 2026 10:13
Signed-off-by: John Tennant <johnmatthewtennant@gmail.com>
Signed-off-by: John Tennant <jtennant@squareup.com>
Signed-off-by: John Tennant <jtennant@squareup.com>
@johnmatthewtennant
johnmatthewtennant force-pushed the jtennant/buzz-voice-mobile-linking-april branch from b1c899f to 6947376 Compare July 31, 2026 14:43
@johnmatthewtennant
johnmatthewtennant changed the base branch from jt/buzz-voice-refactor to main July 31, 2026 14:44
@johnmatthewtennant johnmatthewtennant changed the title feat(voice): add mobile linking and cancellation feat(voice): support mobile linking and cancellation Jul 31, 2026
@johnmatthewtennant
johnmatthewtennant marked this pull request as ready for review July 31, 2026 14:48
@johnmatthewtennant
johnmatthewtennant requested a review from a team as a code owner July 31, 2026 14:48
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