GetSpeechRate ()? (or how to determine which TTS bid is currently set)

TextToSpeech has a way to set speech speed: setSpeechRate () . But it does not have the opposite method of querying the current speed.

Is there a way to query the system for this value?

+4
source share
2 answers

You can get the default speech speed of TTS

Settings.Secure.getInt(getContentResolver(), Settings.Secure.TTS_DEFAULT_RATE, 100) / 100f; 
+1
source

I was looking for a similar thing, and it looks like there really is no such method. But since 1.0 is the normal speed of speech , I solved it by storing the speed in my variable. I have a class that provides several methods for working with TTS, so here is my implementation:

 public class MyTts { private static float rate = 1.0f; ... public float getSpeechRate() { return rate; } public int setSpeechRate(float rt) { rate = rt; return tts.setSpeechRate(rate); } ... } 

Where setSpeechRate returns TextToSpeech.ERROR or TextToSpeech.SUCCESS according to the documentation.

Edit: It looks like when I set the speed, i.e. 1.5f, and then back to 1.0f, this is not the same. It depends on the tts settings in Android.

0
source

All Articles