feat(stt): pass last assistant response as Whisper context to reduce mishearings

This commit is contained in:
2026-04-07 09:57:07 -04:00
parent d75d34ce8e
commit 36350d35b1
3 changed files with 18 additions and 6 deletions
+9 -2
View File
@@ -108,6 +108,10 @@ class VoiceNotifier extends Notifier<VoiceState> {
int _lastSeenLength = 0;
bool _streamComplete = false;
// Last complete assistant response — passed to Whisper as initial_prompt
// to reduce STT mishearings of domain-specific words.
String _lastAssistantContent = '';
// TTS playback queue
final _ttsQueue = Queue<Uint8List>();
bool _ttsPlaying = false;
@@ -205,6 +209,7 @@ class VoiceNotifier extends Notifier<VoiceState> {
_dispatchSentences(flush: isComplete);
if (isComplete) {
_lastAssistantContent = fullContent;
_streamComplete = true;
_checkRestartListening();
}
@@ -278,8 +283,10 @@ class VoiceNotifier extends Notifier<VoiceState> {
if (!state.voiceModeActive) return;
final transcript =
await ref.read(voiceRepositoryProvider).transcribe(bytes);
final transcript = await ref.read(voiceRepositoryProvider).transcribe(
bytes,
context: _lastAssistantContent.isNotEmpty ? _lastAssistantContent : null,
);
if (!state.voiceModeActive) return;