I'm working in android using the TextToSpeech class and Have a string with and specific length. I want to calculate the estimated time of this generated text to speech audio (I know that i can get the audio and then get the time length of this generated audio but I want to explore other alternatives).
I'm trying getting the speechRate (but seems no posible) and the with the length of the String create some formula getting as result an estimation of the time.
Any sugestions??
Thanks in advance.
PD: About the spechRate: getSpeechRate()? (or how to tell what rate TTS is currently set at)
I use int pauseInSeconds=1+string.length()/7 for short english speaking.
Very rough of course.
You can do something like this:
private void speakWord(String word)
{
//Get time
textToSpeech.speak(...);
checkSpeaking(true);
}
private void checkSpeaking(boolean isSpeaking)
{
Print.e("Speaking is: " + isSpeaking);
if (isSpeaking)
{
new Handler().postDelayed(()->
{
if (textToSpeech.isSpeaking()) {
checkSpeaking(true);
}
else {
checkSpeaking(false);
}
},300);
}
else
{
//Get time
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With