Repository navigation
feat(voice): a second, grammar-only decode makes commands reliable - #80
Merged
Merged
Conversation
The small Vosk model mishears short commands on the robot's mic ("weder mit
dem schwanz", "legt dich hin"). Each finished phrase is decoded again
against only the command vocabulary plus the wake words (70-250 ms on the
Pi 4, measured). A grammar forces everything into its words — a question came
out as "nox sitz dreh hallo geh" — but those forced words score 0.47-0.86
while real commands score 1.00, so the grammar text replaces the transcript
only when every word is >= 0.95. VOICE_COMMAND_GRAMMAR=0 turns it off.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…er the echo filters - A grammar does not emit words it doesn't know, so a confident reading could shrink "nox wie spät ist es" to "nox". It must now have as many words as the full transcript. - The replacement happens only after the echo and self-echo checks, which test both readings, so the dog's own words can't become a command. - The utterance buffer keeps at most 30 s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Field report: voice commands are understood badly. The small Vosk model on the robot's cheap mic produces things like "legt dich hin" and "weder mit dem schwanz".
Change: every finished phrase is decoded a second time with a Vosk grammar that contains only command words and wake words (de/en/fr, chosen from the model name).
Problem with grammars: a grammar pushes every utterance into its vocabulary. Measured on the dog: "Nox, was siehst du gerade vor dir?" comes out as
nox sitz dreh hallo geh.Fix for that: word confidence. The forced words scored 0.47–0.86, real commands scored 1.00 throughout. So the grammar text is used only when every word reaches ≥ 0.95. Otherwise the full transcript goes on as before.
Validated on the dog with 10 German test phrases:
VOICE_COMMAND_GRAMMAR=0turns it off.🤖 Generated with Claude Code