Skip to content

Commit

Permalink
fix: set first TTS voice when changing language
Browse files Browse the repository at this point in the history
  • Loading branch information
blockbasti committed Jan 25, 2022
1 parent 531683c commit 0190bb4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/tts_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ class TTSHelper {
if(!available) return;
Prefs.setString("tts_lang", languageCode);
await flutterTts.setLanguage(languageCode);

var ttsVoice = voices.firstWhere((voice) => voice.locale == languageCode).name;
await Prefs.setString('tts_voice', ttsVoice);
await flutterTts.setVoice({"name": ttsVoice, "locale": languageCode});
}

static void speak(String text) async {
Expand Down

0 comments on commit 0190bb4

Please sign in to comment.