Files
wehub-resource-sync 426e9eeabd
Voice Workbench / headless workbench (mocked backends) (push) Has been cancelled
Voice Workbench / real acoustic lane (nightly, provisioned only) (push) Has been cancelled
ci / test (push) Has been cancelled
ci / lint-and-format (push) Has been cancelled
ci / build (push) Has been cancelled
ci / dev-startup (push) Has been cancelled
gitleaks / gitleaks (push) Has been cancelled
Markdown Links / Relative Markdown Links (push) Has been cancelled
Quality (Extended) / Homepage Build (PR smoke) (push) Has been cancelled
Quality (Extended) / Comment-only diff guard (push) Has been cancelled
Quality (Extended) / Format + Type Safety Ratchet (push) Has been cancelled
Quality (Extended) / Develop Gate (secret scan + UI determinism) (push) Has been cancelled
Quality (Extended) / Develop Gate (lint) (push) Has been cancelled
Chat shell gestures / Chat shell gesture + parity e2e (push) Has been cancelled
Cloud Gateway Discord / Test (push) Has been cancelled
Benchmark Bridge Tests / benchmark (bunx @biomejs/biome check packages/lifeops-bench/src, benchmark-lint) (push) Has been cancelled
Benchmark Bridge Tests / benchmark (bunx vitest run --config packages/lifeops-bench/vitest.config.ts --root packages/lifeops-bench --passWithNoTests, benchmark-tests) (push) Has been cancelled
Build Agent Image / build-and-push (push) Has been cancelled
Dev Smoke / bun run dev onboarding chat (push) Has been cancelled
Dev Smoke / Vite HMR dependency-level smoke (push) Has been cancelled
Electrobun Submodule Guard / electrobun gitlink is fetchable (push) Has been cancelled
Publish @elizaos/example-code / check_npm (push) Has been cancelled
Publish @elizaos/example-code / publish_npm (push) Has been cancelled
Publish @elizaos/plugin-elizacloud / verify_version (push) Has been cancelled
Publish @elizaos/plugin-elizacloud / publish_npm (push) Has been cancelled
Sandbox Live Smoke / Sandbox live smoke (push) Has been cancelled
Snap Build & Test / Build Snap (amd64) (push) Has been cancelled
Snap Build & Test / Build Snap (arm64) (push) Has been cancelled
Test Packaging / elizaos CLI global-install smoke (node + bun) (push) Has been cancelled
Cloud Gateway Webhook / Test (push) Has been cancelled
Cloud Tests / lint-and-types (push) Has been cancelled
Cloud Tests / unit-tests (push) Has been cancelled
Cloud Tests / integration-tests (push) Has been cancelled
Cloud Tests / e2e-tests (push) Has been cancelled
CodeQL Advanced / Analyze (javascript-typescript) (push) Has been cancelled
Deploy Apps Worker (Product 2) / Determine environment (push) Has been cancelled
Deploy Apps Worker (Product 2) / Deploy apps worker to apps-control host (${{ needs.determine-env.outputs.environment }}) (push) Has been cancelled
Deploy Eliza Provisioning Worker / Determine environment (push) Has been cancelled
Deploy Eliza Provisioning Worker / Deploy worker to Hetzner host (${{ needs.determine-env.outputs.environment }} @ ${{ needs.determine-env.outputs.deployment_sha }}) (push) Has been cancelled
Dev Smoke / Classify changed paths (push) Has been cancelled
supply-chain / sbom (push) Has been cancelled
supply-chain / vulnerability-scan (push) Has been cancelled
Build, Push & Deploy to Phala Cloud / build-and-push (push) Has been cancelled
Test Packaging / Validate Packaging Configs (push) Has been cancelled
Test Packaging / Build & Test PyPI Package (push) Has been cancelled
Test Packaging / PyPI on Python ${{ matrix.python }} (push) Has been cancelled
Test Packaging / Pack & Test JS Tarballs (push) Has been cancelled
UI Fixture E2E / ui-fixture-e2e (push) Has been cancelled
UI Fixture E2E / fixture-e2e (push) Has been cancelled
UI Story Gate / story-gate (push) Has been cancelled
vault-ci / test (macos-latest) (push) Has been cancelled
vault-ci / test (ubuntu-latest) (push) Has been cancelled
vault-ci / test (windows-latest) (push) Has been cancelled
vault-ci / app-core wiring tests (push) Has been cancelled
verify-patches / verify patches/CHECKSUMS.sha256 (push) Has been cancelled
Voice Benchmark Smoke / voice-emotion fixture smoke (push) Has been cancelled
Voice Benchmark Smoke / voiceagentbench fixture smoke (push) Has been cancelled
Voice Benchmark Smoke / voicebench-quality unit smoke (push) Has been cancelled
Voice Benchmark Smoke / voicebench TypeScript unit (no audio) (push) Has been cancelled
Voice Benchmark Smoke / voice bench smoke summary (push) Has been cancelled
Windows CI / windows ([bun run --cwd packages/app-core test bun run --cwd packages/elizaos test bun run --cwd packages/cloud/shared test], app-and-cli) (push) Has been cancelled
Windows CI / windows ([bun run --cwd packages/scenario-runner test bun run --cwd packages/vault test bun run --cwd packages/security test bun run --cwd plugins/plugin-coding-tools test], framework-packages) (push) Has been cancelled
Windows CI / windows ([bun run --cwd plugins/plugin-elizacloud test bun run --cwd plugins/plugin-discord test bun run --cwd plugins/plugin-anthropic test bun run --cwd plugins/plugin-openai test bun run --cwd plugins/plugin-app-control test bun run --cwd plugins/pl… (push) Has been cancelled
Windows CI / windows ([node packages/scripts/run-turbo.mjs run build --filter=@elizaos/core --filter=@elizaos/shared --filter=@elizaos/agent --concurrency=4 node packages/scripts/run-bash-linux-only.mjs scripts/verify-riscv64-buildpaths.sh node packages/scripts/run… (push) Has been cancelled
Windows CI / windows ([node packages/scripts/run-turbo.mjs run typecheck --filter=@elizaos/core --filter=@elizaos/shared --filter=@elizaos/cloud-shared --concurrency=4 bun run --cwd packages/core test bun run --cwd packages/shared test], core-runtime, 75) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:43:05 +08:00

4.3 KiB

Android raw-PCM frame capture (audioFrame)

Adds an opt-in native AudioRecord path to TalkModePlugin.kt that streams 16 kHz mono 16-bit PCM frames to JS as a new audioFrame Capacitor event, so a JS/bun consumer can run diarization / frame-VAD / wake-word on Android. The default SpeechRecognizer (SODA) STT path is untouched and remains the default.

Why a new path was needed

Android STT (android.speech.SpeechRecognizer) yields transcript strings onlyonBufferReceived is a documented no-op on SODA, so there is no raw PCM, and diarization/VAD/wake-word can't run. The new path captures PCM directly with AudioRecord.

The mic-contention constraint and the chosen design

Android lets only one capture client own a given audio input at a time. A parallel AudioRecord while SpeechRecognizer holds the mic does not get the mic — AudioRecord either fails to reach RECORDSTATE_RECORDING or reads silence. The three options from the brief:

  • (a) AudioRecord-only mode replacing SpeechRecognizer (PCM -> local-inference ASR).
  • (b) Coexistence, if the device permits it.
  • (c) A distinct "diarization mode" that suspends SpeechRecognizer while AudioRecord runs.

Chosen: (c). startAudioFrames detects an active SpeechRecognizer session and suspends it (recognizer.cancel() + destroy(), cancel the restart/silence jobs) before opening AudioRecord; stopAudioFrames releases AudioRecord and resumes SpeechRecognizer if a session is still active (enabled && !stopRequested). This is the cleanest viable path that does NOT regress the working SODA STT default: it is a separate opt-in method; start() is unchanged and frame capture is off unless explicitly requested.

Coexistence (b) was measured infeasible on the Pixel 9a (see verification): AudioRecord reaches RECORDING and frames flow only AFTER STT is suspended; the design proactively suspends rather than relying on concurrent capture.

Option (a) — AudioRecord-only + local transcription — is a strict superset of this PCM capture (the PCM produced here is exactly what a local-ASR consumer would feed to local ASR). It is left to the JS consumer: this layer's job is to deliver verified PCM frames; transcription backend choice lives above it.

API (added)

  • startAudioFrames({ sampleRate = 16000, frameMs = 20 }) → { started, sampleRate, frameSamples, suspendedStt, error? }
  • stopAudioFrames() → void
  • isCapturingAudioFrames() → { capturing }
  • Event audioFrame: { pcm16 (base64 LE s16 mono), sampleRate, channels: 1, samples, rms (0..1), timestamp (elapsedRealtime ms), frameIndex }

The AudioRecord is opened on VOICE_RECOGNITION (preprocessing-light, what diarization wants), falling back to MIC. The read loop runs on Dispatchers.IO; each frame is little-endian-packed, RMS-measured, base64-encoded, and emitted via notifyListeners. Lifecycle is released in stop() and handleOnDestroy().

On-device verification (Pixel 9a, 53081JEBF11586)

Driven via CDP against the WebView Capacitor context (TalkMode plugin), with mic permission granted:

  1. PCM frames reach JS (frame-only): startAudioFrames({16000, 20ms})started:true, sampleRate:16000, frameSamples:320. 196 frames in 4 s (~49 fps = correct for 20 ms frames), samples:320, channels:1, sampleRate:16000, base64 length 856 (= 640 PCM bytes), RMS varied per frame (min 0.00007, max 0.00679, avg 0.00465 → live audio, not a silence stub), frameIndex strictly monotonic, capturing true→false across start/stop.
  2. Mic contention / suspend-resume: start() (STT, state:listening) → startAudioFrames() returned suspendedStt:true and captured 149 frames (avg RMS 0.00485) while STT was suspended → stopAudioFrames() resumed STT (state:listening, enabled:true). Proves AudioRecord only gets the mic once SpeechRecognizer is suspended, and STT cleanly resumes.
  3. No STT regression: default start()started:true, state:listening, enabled:true; isCapturingAudioFrames stays false (frame capture is off unless explicitly requested).

Build: :elizaos-capacitor-talkmode:compileDebugKotlin + :app:assembleDebug (BUILD SUCCESSFUL); APK contains startAudioFrames/audioFrame in the dex; installed + verified on-device.