fix(voice): eliminate dual-recorder conflict and defunct element crashes

VadHandler is now the sole mic owner — removed separate AudioRecorder that
caused audio focus contention on Android. Audio from onSpeechEnd is encoded
as WAV for Whisper. Provider switched to autoDispose to match widget lifecycle,
preventing defunct element assertions. Recording UI deferred until mic is open.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-17 08:04:03 -04:00
parent 413b82f724
commit fc6c9648f9
8 changed files with 160 additions and 115 deletions
+3 -3
View File
@@ -40,7 +40,7 @@ class VoiceApi {
}
}
/// POST WebM/Opus audio bytes and return the transcript string.
/// POST audio bytes (WAV) and return the transcript string.
/// [context] is optional recent conversation text passed as initial_prompt
/// to Whisper, reducing mishearings of domain-specific words.
/// Returns empty string on empty or error response.
@@ -49,8 +49,8 @@ class VoiceApi {
final fields = <String, dynamic>{
'audio': MultipartFile.fromBytes(
audioBytes,
filename: 'audio.m4a',
contentType: DioMediaType('audio', 'mp4'),
filename: 'audio.wav',
contentType: DioMediaType('audio', 'wav'),
),
if (context != null && context.isNotEmpty) 'context': context,
};