Skip to content

feat(speech): add LlamaCppLiveAsrAdapter and public streaming routing - #2055

Merged
leehack merged 12 commits into
mainfrom
feat/327-live-asr-public
Nov 18, 2026
Merged

leehack merged 12 commits into
mainfrom
feat/327-live-asr-public

Conversation

@leehack

@leehack leehack commented Nov 18, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Add LlamaCppLiveAsrAdapter (sealed SpeechToTextAdapter subtype) and SpeechToTextCapabilities.streamingInputUnsupportedReason for native incremental live PCM speech recognition on llama.cpp (Voxtral Realtime and LFM3-Audio) via SpeechToTextEngine.load, startStream(), and complete-PCM transcribe/transcribeOnce.
  • Add optional BackendStreamingSpeechToText, BackendStreamingSpeechToTextSession, and BackendStreamingSpeechToTextUpdate SPI to lib/backend.dart, LlamaEngineBackendHooks, NativeLlamaBackend, and NativeAutoBackend.
  • Add example/basic_app/bin/llamadart_live_asr_example.dart (with SIGINT cancellation handling), update README.md, MIGRATION.md, CHANGELOG.md, website docs/migration/changelog, skills/llamadart-{speech,web}/SKILL.md, capability_coverage.json, and speech-to-text-stream-smoke (env-configurable paths, JFK keyword content checks, no-silent-loss bounds, cancel-before-first-step / cancel-during-blocked-push / cancel-after-first-text + immediate reuse, per-model peakCurrentRssMB, and LLAMADART_STT_LIVE_PACED=1 300 s live-paced qualification).
  • Merged origin/main (a60436bfa3fd3eefc0c6776b723726c9cfc2f9be, squash-merge of feat(llama_cpp): add internal live ASR native service and worker protocol #2054) and retargeted feat(speech): add LlamaCppLiveAsrAdapter and public streaming routing #2055 to main, after addressing all deep-audit and delta-audit P2/P3 findings.

Refs #327

Production-readiness scope

  • User-facing scope: Native apps can stream mono 16 kHz normalized float32 PCM incrementally or as one buffer through SpeechToTextEngine with LlamaCppLiveAsrAdapter, receiving cumulative confirmed partial events and a final transcript.
  • Supported platforms/paths: Native platforms with llamadart-native@v1.0.0-1+ (Voxtral-Mini-4B-Realtime-2602 and LFM3-Audio-2B GGUF + audio projector). Qualified locally on macOS arm64 CPU (numberOfThreads: 2, numberOfThreadsBatch: 2) in fast and 300 s live-paced runs.
  • Unsupported or intentionally unavailable paths: Web rejects LlamaCppLiveAsrAdapter with LlamaUnsupportedException before model resolution/download/bridge calls. Older native runtimes, mismatched projectors (including Qwen3-ASR), and LFM3-Audio below 2,048 per-sequence context capacity throw LlamaUnsupportedException. attach remains prompt-only; file/encoded-byte inputs, languageHint, and contextPrompt are rejected.
  • Out of scope / follow-ups: Physical-platform/mobile capture, Windows/Linux/GPU qualification, and chat-app UI picker remain open under Complete remaining live STT modes and cross-platform validation #327.

Completeness checklist

  • Declared scope is fully implemented, or explicitly reduced above.
  • Unsupported platform/option combinations fail loudly with actionable diagnostics or are clearly documented as unavailable.
  • Public API docs, README/website docs, examples, support matrices, and changelog entries are updated where relevant.
  • Regression coverage covers the original issue plus key negative/version-skew paths where relevant.
  • Public capability changes update the validation coverage registry with a pack or a reasoned, issue-linked exemption; inventory checks pass.
  • Security/privacy review completed: no secrets, bearer tokens, signed URLs, or raw secret-bearing paths leak through logs, cache keys, metadata, errors, or snapshots.
  • Follow-up work that is useful but not required for this PR is tracked in GitHub Issues (Complete remaining live STT modes and cross-platform validation #327).

PR type guidance

  • Feature PR: includes LlamaCppLiveAsrAdapter + BackendStreamingSpeechToText SPI, llamadart_live_asr_example.dart, docs/migration/skills/changelog updates, unit/Web/E2E tests.

Test Plan

  • python3 tool/ci/check_format.py (1895 files, 0 changed) — at 1c1e6e9ee
  • dart analyze (0 issues) — at 1c1e6e9ee
  • dart run tool/testing/check_platform_boundaries.dart (OK) — at 1c1e6e9ee
  • cd example/basic_app && dart analyze && dart test (0 issues, +51 ~12 passed) — at 1c1e6e9ee
  • dart test -p chrome --exclude-tags local-only (+4945 ~1 passed) — at 1c1e6e9ee
  • ./tool/docs/build_site.sh (4272 pages, 64 in sitemap, no broken internal links) — at 1c1e6e9ee
  • coverage-lib (+14929 ~135 passed, 93.78% LCOV (36134/38531)) — at 1c1e6e9ee
  • Earlier 7d67893877 checks (unchanged across origin/main merge): test/unit/core/speech/ test/unit/tooling/ (+2184 ~11 passed), llamadart_live_asr_example.dart SIGINT cancellation (Cancelled. + exit 130), unset-env dart test --run-skipped -t local-only test/e2e/backends/speech_to_text_stream_e2e_test.dart (~3 clean skip)
  • Earlier c38c393d2b real-model E2E check: TMPDIR="$(mktemp -d)" dart test --run-skipped -t local-only test/e2e/backends/speech_to_text_stream_e2e_test.dart (fast mode, macOS arm64 real models: Voxtral Realtime 300s fast, LFM3-Audio 2048 restart + 300s fast, Qwen3-ASR refusal, JFK keyword + >=25 repetition bounds, cancel-before-first-step / cancel-during-blocked-push / cancel-after-first-text + immediate reuse: +3 passed)
  • Earlier eeb8e84ca8 check: LLAMADART_STT_LIVE_PACED=1 300 s live-paced run

Matrix Evidence

Matrix row Scope covered Platform / model / backend Result Evidence / notes
static-format-analyze format, analyzer, boundaries macOS arm64 (1c1e6e9ee) PASS 0 format changes (1895 files), 0 analyze issues, boundaries OK
coverage-lib full VM unit/integration + LCOV >=70% macOS arm64 (1c1e6e9ee) PASS +14929 ~135 passed, 93.78% LCOV (36134/38531)
root-chrome browser-compatible unit/integration macOS arm64 / Chrome (1c1e6e9ee) PASS +4945 ~1 passed
speech-to-text-stream-smoke Voxtral Realtime, LFM3-Audio, Qwen3 refusal, 300s fast, JFK content/reps, cancel/reuse macOS arm64 CPU (c38c393d2b, 2/2 threads) PASS +3 passed (wall=52062ms Voxtral fast, wall=7112ms LFM3 fast)

300 s Live-ASR Qualification (macOS arm64 CPU, threads=2/2)

Model Mode Head Wall (ms) First partial wall (ms) First partial audio (ms) Flush/finalize (ms) Baseline RSS (MB) Peak current RSS (MB)
Voxtral-Mini-4B-Realtime-2602-Q4_K_M.gguf fast c38c393d2b 52062 408 1600 208 4290.4 4615.3
LFM3-Audio-2B-Q4_K_M.gguf fast c38c393d2b 7112 38 1280 18 1992.4 1993.7
Voxtral-Mini-4B-Realtime-2602-Q4_K_M.gguf live-paced (300 s) eeb8e84ca8 300204 1343 1600 200 4106.0 8245.4*
LFM3-Audio-2B-Q4_K_M.gguf live-paced (300 s) eeb8e84ca8 300033 1014 1280 30 1856.8 8245.4*

*Note: Fast runs at c38c393d2b measure per-model peakCurrentRssMB (ProcessInfo.currentRss max). Earlier eeb8e84ca8 live-paced rows reflect process-lifetime ProcessInfo.maxRss.

Mutation Check Before / After (Audit d860a618a -> c38c393d2b)

Suite Before (d860a618a) After (c38c393d2b9d10ea3b899dbaadbfae0df67fabb8) Notes
Code mutants (M01–M26) 16/26 killed (10 survived) 24/26 killed Killed M06, M11, M13, M15, M17, M18, M23, M26. M19 is an equivalent mutant on _LlamaCppStreamingSession (addPcm throws LlamaStateException when _cancelled is true, caught by _pipeStreamingTask, verified pushCalls == 0). M24 is unreachable via public SpeechToTextEngine.
Tooling mutants (T1–T3) 2/3 killed (T1 survived) 3/3 killed test/unit/tooling/test_matrix_test.dart now pins speech-to-text-stream-smoke (T1 killed).

Review Notes

  • Independent review status: READY at 1c1e6e9ee against main a60436bfa (Opus 5.5 auditor-deep sessions: full at d860a618a, deltas at b0507331d and 1c1e6e9ee); 0 P1/P2; merge of main verified mechanical; CI 36 pass / 9 path-skipped; coverage-lib 93.78%; evidence llamadart-evidence/pr-2055/audit-1c1e6e9ee/.
  • CI status / head SHA: 1c1e6e9ee7e725fd8caf584dde873bfb896287e1

High-risk regression review

  • Classification: high-risk (backendRuntime, regressionPolicy, structuredOutput)
  • Implementation task: PR 2 (feat/327-live-asr-public)
  • Independent blocking QA task: separate Opus 5.5 auditor-deep sessions (READY at 1c1e6e9ee)
  • Exact head / current base: 1c1e6e9ee7e725fd8caf584dde873bfb896287e1 / main (a60436bfa3fd3eefc0c6776b723726c9cfc2f9be)
  • Production-branch deletion, bypass, or miswire proof: Readiness evaluator: exits 1 (missingStructuredOutputEvidence) because lib/backend.dart gains three export names (BackendStreamingSpeechToText, BackendStreamingSpeechToTextSession, BackendStreamingSpeechToTextUpdate). Maintainer waiver (leehack, 2026-11-18): one-time export-only waiver per Let export-only public entrypoint diffs skip structured-output minima #1806; no structured-output evidence is claimed.
  • Affected-family real-model/artifact evidence: speech-to-text-stream-smoke on Voxtral-Mini-4B-Realtime-2602-Q4_K_M.gguf, LFM3-Audio-2B-Q4_K_M.gguf, Qwen3-ASR-0.6B-Q8_0.gguf
  • Explicit unavailable-family or other N/A evidence: Web, Windows, Linux, mobile, GPU backends
  • Known PR-caused P1 regressions: 0
  • Unresolved review threads: 0

Base automatically changed from feat/327-live-asr-native-service to main November 18, 2026 20:25
# Conflicts:
#	lib/src/backends/llama_cpp/llama_cpp_backend.dart
#	test/unit/backends/llama_cpp/llama_cpp_backend_test.dart
@leehack
leehack marked this pull request as ready for review November 18, 2026 21:36
@leehack
leehack merged commit 540ab02 into main Nov 18, 2026
77 of 79 checks passed
@leehack
leehack deleted the feat/327-live-asr-public branch November 18, 2026 21:36
@github-actions

Copy link
Copy Markdown
Contributor

Chat app preview removed for leehack/llamadart-chat-pr-2055.

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