From b13c1b52be038b9191df5592c5ab230c4cc25be0 Mon Sep 17 00:00:00 2001 From: Severin von Wnuck-Lipinski Date: Wed, 3 Jul 2024 21:44:35 +0200 Subject: [PATCH] Use default system TTS language Calling TextToSpeech.setLanguage overrides the TTS language set by the user in the system settings. --- .../freeyourgadget/gadgetbridge/util/GBTextToSpeech.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/GBTextToSpeech.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/GBTextToSpeech.java index 31158899c..682f9cb6a 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/GBTextToSpeech.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/GBTextToSpeech.java @@ -9,8 +9,6 @@ import android.speech.tts.UtteranceProgressListener; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.Locale; - public class GBTextToSpeech { private static final Logger LOG = LoggerFactory.getLogger(GBTextToSpeech.class); @@ -38,9 +36,8 @@ public class GBTextToSpeech { private void initializeTTS(UtteranceProgressListener callback) { textToSpeech = new TextToSpeech(context, status -> { if (status == TextToSpeech.SUCCESS) { - int result = textToSpeech.setLanguage(Locale.getDefault()); - if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) { - LOG.error("TTS returned error: Language not supported."); + if (textToSpeech.getVoice() == null) { + LOG.error("TTS returned error: No voice available."); } else { this.isConnected = true; textToSpeech.setOnUtteranceProgressListener(callback);