0

I have an Android TV app, running on a Fire TV Stick. I have initialized a TextToSpeech engine and I am calling it via the speak function. My problem is that the speech rate (talk back speed) does not change when I change those in settings. I know that I am able to set the speech rate to a float of my liking using setSpeechRate(rate), but I would like to know how to get the rate from the system.

I have so far tried to use: Settings.Secure.getString(contentResolver, Settings.Secure.TTS_DEFAULT_RATE); which returns null, and Settings.Secure.getInt(contentResolver, Settings.Secure.TTS_DEFAULT_RATE); which throws a SettingNotFound error. If I give it a fallback value, it will just always use that no matter how I change the system VoiceView settings. My code roughly does the following:

TextToSpeech engine = new TextToSpeech(context, this);
ContentResolver contentResolver = context.getContentResolver();
int speechRate = Settings.Secure.getInt(contentResolver, Settings.Secure.TTS_DEFAULT_RATE, 100);
engine.setSpeechRate((float)(speechRate / 100));
engine.speak("This is a sample sentence", QUEUE_FLUSH, null, utteranceID);

I am hesitant to write to the settings, because 1) I don't want to require extra write permissions; 2) Even if I write to it, it seems that changing the system settings will not change this setting, which is my end goal.

Is there some other way to get accessibility settings like VoiceView speed in Android?

Sander Shi
  • 33
  • 1
  • 7
  • your code seems correct mDefaultRate = android.provider.Settings.Secure.getInt(resolver, TTS_DEFAULT_RATE); this is how Google extract the default rate according to https://android.googlesource.com/platform/packages/apps/Settings/+/8bd2feb/src/com/android/settings/tts/TextToSpeechSettings.java – Angel Koh Jan 29 '20 at 01:50
  • Thanks for responding! It seems that FireTV functions a little differently from other Android TV devices and does not use the same secure settings if it does use those settings at all. – Sander Shi Feb 05 '20 at 01:33

0 Answers0