mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 04:53:36 +00:00
[android] fix crash when no TTS engine
Signed-off-by: gekeleda <git@davidgekeler.eu>
This commit is contained in:
@@ -10,6 +10,7 @@ import android.os.Looper;
|
||||
import android.provider.Settings;
|
||||
import android.speech.tts.TextToSpeech;
|
||||
import android.speech.tts.UtteranceProgressListener;
|
||||
import android.speech.tts.Voice;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Pair;
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -280,13 +281,16 @@ public enum TtsPlayer
|
||||
|
||||
public Locale getVoiceLocale()
|
||||
{
|
||||
return mTts.getVoice().getLocale();
|
||||
if (INSTANCE.mTts == null)
|
||||
return null;
|
||||
Voice voice = INSTANCE.mTts.getVoice();
|
||||
return voice != null ? voice.getLocale() : null;
|
||||
}
|
||||
|
||||
public String getLanguageDisplayName()
|
||||
{
|
||||
Locale locale = getVoiceLocale();
|
||||
return locale.getDisplayName(locale);
|
||||
return locale != null ? locale.getDisplayName(locale) : null;
|
||||
}
|
||||
|
||||
public void speak(String textToSpeak)
|
||||
|
||||
Reference in New Issue
Block a user