Peter Michael Gits Claude commited on
Commit
5d2f2af
·
1 Parent(s): f7f39b9

fix: Configure MediaRecorder with consistent WebM/Opus format

Browse files

- Fix root cause of "Thank you very much" repetitive transcriptions
- Configure MediaRecorder with audio/webm;codecs=opus for consistent encoding
- Add 128kbps audio bitrate for good quality
- Prevent "EBML header parsing failed" errors in STT service
- Follow unmute.sh methodology for WebM format consistency
- Add fallback handling for browsers without WebM/Opus support

Resolves STT service logs showing corrupted WebM files causing
ffmpeg conversion failures and silence fallback transcriptions.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

webrtc/server/fastapi_integration.py CHANGED
@@ -205,7 +205,18 @@ def create_fastapi_app() -> FastAPI:
205
  console.log('Microphone access granted');
206
  addTranscription('Microphone access granted', new Date().toISOString());
207
 
208
- mediaRecorder = new MediaRecorder(audioStream);
 
 
 
 
 
 
 
 
 
 
 
209
 
210
  mediaRecorder.ondataavailable = function(event) {
211
  console.log('Audio chunk available, size:', event.data.size);
 
205
  console.log('Microphone access granted');
206
  addTranscription('Microphone access granted', new Date().toISOString());
207
 
208
+ // Configure MediaRecorder with consistent WebM/Opus format (unmute.sh methodology)
209
+ const mimeType = 'audio/webm;codecs=opus';
210
+ if (!MediaRecorder.isTypeSupported(mimeType)) {
211
+ console.warn('WebM/Opus not supported, falling back to default format');
212
+ mediaRecorder = new MediaRecorder(audioStream);
213
+ } else {
214
+ console.log('Using WebM/Opus format for consistent encoding');
215
+ mediaRecorder = new MediaRecorder(audioStream, {
216
+ mimeType: mimeType,
217
+ audioBitsPerSecond: 128000 // 128 kbps for good quality
218
+ });
219
+ }
220
 
221
  mediaRecorder.ondataavailable = function(event) {
222
  console.log('Audio chunk available, size:', event.data.size);