Repository navigation
Conversation
f1a9883 to
1ad406c
Compare
There was a problem hiding this comment.
Request changes (2 P1)
Scope: base main, merge base fb6812dc; 1 commit and 24 files reviewed at 1ad406c5. Loaded the ponytail-review skill. coderbook and karpathy-guidelines were not loaded, so their review passes were applied from the skill's checklist only. Ran in a separate session.
Findings
P1
1. TeamHub still refuses to create a dictation session without a Soniox key, so local dictation never starts (apps/teamhub/internal/app/handlers_voice_media.go:52-63)
createVoiceSession resolves voicekey.Soniox for every purpose except chat_live. If the key is empty, it returns voicemedia.ErrProviderUnavailable, which writeVoiceMediaError (handlers_voice_media.go:268) turns into 503 VOICE_MEDIA_UNAVAILABLE. This PR does not touch this handler. The scenario the PR describes is VOICE_LOCAL_ASR=on, a model directory set, and no Soniox key. In that setup:
voice_media_policy.go:33reportsdictation_supported: true, so Pocket notes and Voice Mode show dictation.- node-services starts the local ASR worker.
- The first
POST /voice-sessionswithpurpose: chat_dictationthen fails with 503.
Nothing in the PR reaches the new LocalASRProvider end to end. The PR's tests cover config parsing, workerKeys and a Web flag. None of them create a session.
Fix: when purpose == PurposeChatDictation && a.cfg.Voice.LocalASR, skip the key requirement. Keep it for hardware_control, which records and needs diarization. Add a handler test that creates a chat_dictation session with no Soniox key and LocalASR on, plus one that shows hardware_control is still refused.
2. Setting VOICE_LOCAL_ASR_MODEL_DIR alone switches every ASR job, recording transcripts included, to the local engine, even when a Soniox key is present (apps/voice-runtime/src/agent.ts:432-466, apps/node-services/src/voice/service.ts:278-288)
spawnWorker spreads the node-services environment (...env) into each child and only blanks SONIOX_API_KEY and XAI_API_KEY. So the ASR worker always inherits VOICE_LOCAL_ASR_MODEL_DIR. In the worker:
agent.tspicksLocalASRProviderwheneverconfig.localAsrModelDiris non-empty, before it looks atsonioxApiKey.- The voice-runtime config never reads
VOICE_LOCAL_ASR.
The linger-voice-runtime agent (agent.ts) also serves hardware_control captures. TeamHub dispatches every purpose except Live to it (internal/voicemedia/livekit_provider.go:133-137). Concrete cases:
- A deployment sets
VOICE_LOCAL_ASR=onplus the model directory and later adds a Soniox key, whichdocs/voice.mdsays "keeps transcription on Soniox". Its dictation and its recording transcripts now run locally, with no speaker labels, punctuation or casing. The only trace is the new warning log. VOICE_LOCAL_ASR=offwith the directory still exported behaves the same way.
The PR body ("Recording still needs Soniox") and the docs both contradict this. The node-services test keeps dictation on Soniox when a key and the local engine exist checks only workerKeys, so it misses the problem. The worker itself decides the opposite.
Fix: the supervisor should decide the engine, not the inherited environment. In spawnWorker, set VOICE_LOCAL_ASR_MODEL_DIR: binding.kind === "local" ? config.localAsrModelDir : "", the same way the provider keys are blanked. Then the warning branch at agent.ts:462-466 cannot be reached and can be deleted. Also fix the LocalASRProvider doc comment, which says it serves "Dictation and recording transcription" (local-asr.ts:613). Add a test on the spawned env, or make agent.ts prefer a non-empty Soniox key.
Verified as fine
- The recorder worker never uses the local engine.
main.ts:27routes--recordertorecorder-agent.ts, which this PR does not change, andworkerKeysstarts the recorder only with a Soniox key (service.ts:97-109). - Worker reconcile treats local as a stable digest (
"local"), so key polling does not restart the local ASR worker (service.ts:172-178). - Older clients and servers: the Web side falls back to
voice_media_supportedwhendictation_supportedis absent (use-pocket-dictation.ts:47,voice-mode-controls.tsx:49). The field is optional in the contract, and the generated files match the OpenAPI edit. - Local-only Web dictation does not need
LiveKitProvider, which mounts only onvoice_media_supported(voice-backend-controller.tsx:137). Pocket dictation opens its own session throughopenVoiceMode(use-pocket-dictation.ts:70-96). - The config is validated in one module per app (
node-services/src/voice/config.ts,teamhub/internal/config/config.go:497). Env vars are listed in.env.exampleandscripts/env-inventory.json.sherpa-onnx-nodeis optional, loaded through a lazyimport(), and marked external in the desktop bundle. LocalASRStreamkeeps one stream handle per dictation stream and shares one recognizer. Events and offsets follow theASRStreamcontract thatASREventQueueconsumes.- No CJK in the added lines or in the commit message.
Not verified
- The real
sherpa-onnx-nodebehaviour (the tests use a fake engine). This covers what happens after a failed addon load, where the provider caches the rejected recognizer promise for the worker's lifetime.
Process notes
- One commit, no merge or fixup commits. The branch is up to date with
main. The merge state is BLOCKED only because it is waiting for review.
CI
All checks pass (changes, computer-go, contracts, desktop, installer, packages, teamhub, teamhub-cli, web, repository-gate, web tests 1/2 and 2/2, web-static). No CI job runs the dictation session creation path that finding 1 breaks. I ran no tests locally.
Automated review by Claude Code
Automated review of 1ad406c by Claude Code.
|
Nice reuse of the ASRProvider seam, but there are two blockers plus merge conflicts: createVoiceSession (handlers_voice_media.go) still requires a Soniox key for chat_dictation, so local dictation without a key fails with 503 before reaching LocalASRProvider. Also please clear #recognizer on load failure so transient errors aren't cached permanently, rebase onto main, and let's confirm the sherpa-onnx-node packaging direction in #337 before merging. |
1ad406c to
dba1c76
Compare
|
Thanks — both P1s and the recognizer cache are fixed, rebased onto
Focused checks pass: TeamHub config + handler tests, node-services typecheck and 9 voice tests, voice-runtime |
Dictation can run on this computer without a Soniox key when VOICE_LOCAL_ASR=on and VOICE_LOCAL_ASR_MODEL_DIR names a streaming zipformer. LocalASRProvider implements the existing ASRProvider seam; the supervisor starts only the ASR worker locally and keeps recording on Soniox. TeamHub exposes dictation_supported independently of recording. Review fixes: createVoiceSession allows local dictation without a key while recording still requires Soniox; spawnWorker sets the model directory only for a local binding and the runtime prefers a Soniox key when present; a failed recognizer load is retried instead of cached.
dba1c76 to
52065dd
Compare
There was a problem hiding this comment.
Request changes (1 P1, 1 P3)
Scope: follow-up on 1ad406c. The branch was rebased onto main (merge base 1c35212b), so I re-reviewed the full merge-base diff: 1 commit and 26 files (lockfile and generated contracts checked only for consistency). Helper skills: coderbook, ponytail-review and karpathy-guidelines were not loaded this run; I applied the review checklist from the linger-pr-review instructions. The review ran in a separate session.
Previous findings
- Resolved: dictation session rejected without a Soniox key.
apps/teamhub/internal/app/handlers_voice_media.go:55skips the key check only forchat_dictationwhenVOICE_LOCAL_ASRis on.voice_local_asr_test.gocovers three cases: local dictation returns 201, recording returns 503, and Soniox dictation without a key returns 503. - Resolved: the model directory overrode Soniox.
apps/node-services/src/voice/service.ts:285passesVOICE_LOCAL_ASR_MODEL_DIRonly to alocalbinding and blanks it for key-bound workers.apps/voice-runtime/src/agent.ts:47also prefers a non-emptySONIOX_API_KEY.
Findings
P1
apps/voice-runtime/src/local-asr.ts:191:finalize()drops the audio still buffered at the end of a turn. A sherpa-onnx streaming zipformer decodes in fixed chunks.isReady()returns true only when a full chunk plus its right context is buffered, which is roughly 0.3–0.6 s for the bilingual model. Right nowfinalize()runs#decode(), emitsfinalandfinalization_ackfor the current hypothesis, and then callsrecognizer.reset(). It never feeds tail padding, so the trailing audio is never decoded into this turn.- Failure scenario:
DictationASRStream.commit()(dictation-asr.ts:116) is the manual-commit path, used for example when Voice Mode sends a turn. If the user says "…send it to Bob" and commits right away, the turn is published without "Bob". Depending on howresettreats the unprocessed frames, the dropped words are either lost or show up at the start of the next turn. - Soniox's
<fin>finalizes all audio sent so far, so this is a behavior difference from the provider this replaces. - The test double in
local-asr.test.tshides the problem:FakeRecognizer.acceptWaveformsetsready = trueafter every frame, so it never models chunk buffering. - Fix: in
finalize(), accept about 0.5–0.66 s of zero samples (the tail padding sherpa-onnx's own examples use) before#decode(). Don't count the padding in#samples. Then flush and reset. Do the same beforeinputFinished()infinish(). Make the fake keep audio pending until a chunk threshold, and add a test where the last words arrive below that threshold.
- Failure scenario:
P3
docs/voice.md:67: "a platform without a loadable build keeps dictation on Soniox" is only true when a Soniox key exists, and then Soniox wins anyway (agent.ts:47). Without a key, TeamHub still reportsdictation_supported: true(voice_media_policy.go:32). Every dictation job then fails when it tries to loadsherpa-onnx-node. Reword the sentence: local dictation requires a loadable build, and a missing addon makes dictation fail.
Verified as fine
- Worker selection:
workerKeys(apps/node-services/src/voice/service.ts:85) starts only theasrworker in local mode, with digest"local". When a key is added or removed,applyreplaces the worker (service.ts:314), and the recorder stays stopped without Soniox. - Recording still needs Soniox:
createVoiceSessionkeeps the key check forhardware_control(handlers_voice_media.go:55). These three are the only purposes (voicemedia/types.go:22). - Old-server compatibility: Web falls back with
dictation_supported ?? voice_media_supported(use-pocket-dictation.ts:41,voice-mode-controls.tsx:48). The contract adds an optional field, and the generated Go/TS match it. - Config:
VOICE_LOCAL_ASRis validated in both TeamHub (config.go:509) and node-services (voice/config.ts:49).VOICE_LOCAL_ASR_MODEL_DIRis inscripts/env-inventory.json.LocalASRProvider.#loadclears a rejected recognizer promise (local-asr.ts:142), so a failed load is retried. - No CJK in added lines or the commit message.
Process notes
- Single commit with no merge commits; the branch is up to date with
main.
CI
- All checks pass. The PR CI does not run the
voice-runtimeandnode-servicesvoice tests, so the new local-ASR tests are covered only by the author's local runs. I didn't run any tests myself.
Automated review by Claude Code
Automated review of 52065dd by Claude Code.
What and why
Implements the proposal in #337. Dictation (Pocket notes and Voice Mode) can now run on the local computer with no Soniox key, so voice works offline and audio never leaves the machine. It is off by default: nothing changes until
VOICE_LOCAL_ASR=onandVOICE_LOCAL_ASR_MODEL_DIRare set, and every existing deployment keeps Soniox exactly as today.apps/voice-runtime:LocalASRProviderimplements the existingASRProvider/ASRStreamseam with a streaming zipformer behind the optionalsherpa-onnx-nodeengine. It emits the samepartial/final/utterance_end/finalization_ackevents, soDictationASRStream,ASREventQueueand the worker stay unchanged.agent.tspicks local or Soniox.apps/node-services: the voice role starts only the ASR worker in local mode, without a key.VOICE_LOCAL_ASR=onrequiresVOICE_LOCAL_ASR_MODEL_DIR, so a misconfiguration fails at startup instead of at the first dictation. Recording still needs Soniox, because only Soniox labels speakers.TeamHub:VoiceMediaPolicygainsdictation_supported, independent ofvoice_media_supported(recording), so the client offers dictation without offering meetings.dictation_supportedand fall back tovoice_media_supportedfor older servers..env.exampleexplain how to download the Apache-2.0 bilingual model and enable it.Measured on Ubuntu 22.04, CPU only, two threads: the 190 MB int8 bilingual model decodes at RTF 0.04 (about 25x realtime) and the first partial arrives under 60 ms; four concurrent streams stay at an aggregate RTF of 0.043. The 25 MB Chinese model runs at RTF 0.015.
Review fixes (rebased onto 1c35212)
createVoiceSessionnow skips the Soniox key only forchat_dictationwhenVOICE_LOCAL_ASRis on.hardware_controlstill requires Soniox, and dictation without the local engine still needs it. Addedvoice_local_asr_test.go: local dictation returns 201, recording returns 503, and Soniox dictation without a key returns 503.spawnWorkernow setsVOICE_LOCAL_ASR_MODEL_DIRonly for a local binding and blanks it for key-bound workers. The voice-runtime agent also prefers a non-emptySONIOX_API_KEYover the local directory, so a leaked directory cannot hijack Soniox jobs. The now-unreachable no-diarization warning was removed, andLocalASRProvider's comment says dictation only.LocalASRProviderclears its cached recognizer promise when a load fails, so a transient engine error is retried instead of poisoning every later stream. Added a test that fails the first load and succeeds the second.TEAMHUB_VOICE_TOOLS_BIN,providerProxy, and the worker-start changes frommainwhile resolving the rebase conflicts.How it was verified
internal/configandinternal/app: local dictation / recording / Soniox dictation table, config parsing, existing purpose-provider test.typecheck,tests/voice/local-asr-worker.test.ts(9), including worker bindings and config validation.src/local-asr.test.ts(7), including the recognizer retry;typecheckand lint on the changed files.voice-runtimesuite still has two unrelated failures in this environment (live-workeraudio timing,provider-proxynetwork_resetvsnetwork_refused); both are untouched by this PR.sherpa-onnx-nodeloaded the bilingual model and transcribed the model's test wavs through the same provider shape; numbers are in Voice: transcribe locally without a Soniox key #337.Boundary
models.jsonand shipping the addon in the desktop runtime are follow-ups; thesherpa-onnx-nodepackaging direction is still to confirm in Voice: transcribe locally without a Soniox key #337.sherpa-onnx-nodeis pinned to 1.12.14 because the current 2.x build needs a newer libstdc++ than Ubuntu 22.04 provides. It is an optional dependency and is marked external in the desktop bundle.