mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-25 08:05:55 +01:00
Use default system TTS language
Calling TextToSpeech.setLanguage overrides the TTS language set by the user in the system settings.
This commit is contained in:
parent
650b3ec7dd
commit
b13c1b52be
@ -9,8 +9,6 @@ import android.speech.tts.UtteranceProgressListener;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
|
|
||||||
public class GBTextToSpeech {
|
public class GBTextToSpeech {
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(GBTextToSpeech.class);
|
private static final Logger LOG = LoggerFactory.getLogger(GBTextToSpeech.class);
|
||||||
@ -38,9 +36,8 @@ public class GBTextToSpeech {
|
|||||||
private void initializeTTS(UtteranceProgressListener callback) {
|
private void initializeTTS(UtteranceProgressListener callback) {
|
||||||
textToSpeech = new TextToSpeech(context, status -> {
|
textToSpeech = new TextToSpeech(context, status -> {
|
||||||
if (status == TextToSpeech.SUCCESS) {
|
if (status == TextToSpeech.SUCCESS) {
|
||||||
int result = textToSpeech.setLanguage(Locale.getDefault());
|
if (textToSpeech.getVoice() == null) {
|
||||||
if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) {
|
LOG.error("TTS returned error: No voice available.");
|
||||||
LOG.error("TTS returned error: Language not supported.");
|
|
||||||
} else {
|
} else {
|
||||||
this.isConnected = true;
|
this.isConnected = true;
|
||||||
textToSpeech.setOnUtteranceProgressListener(callback);
|
textToSpeech.setOnUtteranceProgressListener(callback);
|
||||||
|
Loading…
Reference in New Issue
Block a user