Im making an android application that has text to speech and I want to be able to customize its speech rate. I already have a code for it but i dont know how to apply the speech rate to the whole application.
Here's the settings that I've created for the application. THANKS IN ADVANCE! :D
public float getSpeechRate(){
int checkedRadioButton = this.radioRate.getCheckedRadioButtonId();
if (checkedRadioButton == R.id.rate_slow){
return 0.5f;
} else if (checkedRadioButton == R.id.rate_normal){
return 1.0f;
} else if(checkedRadioButton == R.id.rate_fast){
return 1.5f;
}
return 0;
}
public void setSpeechRate(){
float speechRate = this.getSpeechRate();
if(speechRate == 0.5f){
speakOut("This is a slow speech rate");
} else if(speechRate == 1.0f){
speakOut("This is a normal speech rate");
} else {
speakOut("This is a fast speech rate");
}
This is how I invoke the text to speech
toSpeech = new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener() {
@Override
public void onInit(int status) {
Log.e("TTS", "TextToSpeech.OnInit...");
}
});