fix(desktop): voice decoder handles MediaRecorder MIME params (invalid audio payload) - #815
Merged
Merged
Conversation
…d audio payload) The mic showed 'Voice transcription failed: invalid audio payload'. MediaRecorder emits blobs typed 'audio/webm;codecs=opus', so the recorded data URL is 'data:audio/webm;codecs=opus;base64,<data>' — the mediatype carries a ';codecs=' parameter BEFORE ';base64'. The decoder's regex (^data:([^;,]*)(;base64)?,) assumed a parameter-free mediatype and failed to match, so every real recording was rejected as an invalid payload before the request was ever sent. Rewrote _decode_data_url to split on the first comma (a mediatype can't contain one), detect a trailing ';base64' on the header, and take the base mediatype from everything before the first ';param'. Now audio/webm;codecs= opus, audio/ogg; codecs=opus, and plain audio/wav all decode. Regression test covers the codec-param formats. 62 desktop tests green. Note: the request now reaches the STT endpoint; for a chat-only gateway with no Whisper model it surfaces the existing actionable 'no speech-to-text model' message instead of the cryptic decode error. Co-Authored-By: Claude Fable 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.
The bug
The mic showed "Voice transcription failed: invalid audio payload".
MediaRecorder types its blobs
audio/webm;codecs=opus, so the recorded data URL isdata:audio/webm;codecs=opus;base64,<data>— the mediatype carries a;codecs=parameter before;base64. The decoder's regex^data:([^;,]*)(;base64)?,assumed a parameter-free mediatype and failed to match, so every real recording was rejected before a request was ever sent.Fix
Rewrote
_decode_data_urlto split on the first comma (a mediatype can't contain one), detect a trailing;base64on the header, and take the base mediatype from everything before the first;param. Nowaudio/webm;codecs=opus,audio/ogg; codecs=opus, and plainaudio/wavall decode. Regression test covers the codec-param formats. 62 desktop tests green.Note
The request now reaches the STT endpoint. For a chat-only gateway with no Whisper model (which is the case for the litellm.singula.ai endpoint on this machine — every transcription model name is rejected), it now surfaces the existing actionable "the endpoint doesn't offer a speech-to-text model" message instead of the cryptic decode error. Full transcription needs an OpenAI or Groq provider pointed at a Whisper-capable base URL.
🤖 Generated with Claude Code