Skip to content

fix(desktop): voice decoder handles MediaRecorder MIME params (invalid audio payload) - #815

Merged
agentforce314 merged 1 commit into
mainfrom
fix/desktop-audio-dataurl
Aug 8, 2026
Merged

fix(desktop): voice decoder handles MediaRecorder MIME params (invalid audio payload)#815
agentforce314 merged 1 commit into
mainfrom
fix/desktop-audio-dataurl

Conversation

@agentforce314

Copy link
Copy Markdown
Owner

The bug

The mic showed "Voice transcription failed: invalid audio payload".

MediaRecorder types its blobs 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 before a request was ever sent.

Fix

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 (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

…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>
@agentforce314
agentforce314 merged commit e03bdc8 into main Aug 8, 2026
2 of 3 checks passed
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