fix(tts): Improve speak completion handling to prevent race conditions
This commit is contained in:
@@ -88,7 +88,11 @@ class TextToSpeechService {
|
|||||||
_deviceEngineAvailable = false;
|
_deviceEngineAvailable = false;
|
||||||
try {
|
try {
|
||||||
await _ensureAndroidDefaultEngine();
|
await _ensureAndroidDefaultEngine();
|
||||||
await _tts.awaitSpeakCompletion(false);
|
// Ensure speak() futures complete only after playback finishes.
|
||||||
|
// This avoids race conditions where completion callbacks fire
|
||||||
|
// early in release builds (especially on iOS), which can cause
|
||||||
|
// our voice-call pipeline to resume listening and cut off speech.
|
||||||
|
await _tts.awaitSpeakCompletion(true);
|
||||||
await _tts.setVolume(volume);
|
await _tts.setVolume(volume);
|
||||||
await _tts.setSpeechRate(speechRate);
|
await _tts.setSpeechRate(speechRate);
|
||||||
await _tts.setPitch(pitch);
|
await _tts.setPitch(pitch);
|
||||||
|
|||||||
Reference in New Issue
Block a user