Any one help me for Provide hint in Text to Speech?
My aim is to provide hint which word is reading by devices.
Text to Speech My code is below :-
TextToSpeech tts = new TextToSpeech(this,this);
if (txtText.getText().toString().length() == 0)
tts.speak("You haven't typed text", TextToSpeech.QUEUE_FLUSH, null);
else
tts.speak(txtText.getText().toString(), TextToSpeech.QUEUE_FLUSH,null);
Thanks.
You need to break it down, word by word, and highlight the mentioned word. For e.g. if we take a sentence like "You haven't typed text":
tts.speak("You", TextToSpeech.QUEUE_FLUSH, null);
/*Change size or color of "You" in your TextView for e.g.*/
tts.speak("haven't", TextToSpeech.QUEUE_FLUSH, null);
/*Change size or color of "haven't" in your TextView for e.g.*/
tts.speak("typed", TextToSpeech.QUEUE_FLUSH, null);
/*Change size or color of "typed" in your TextView for e.g.*/
...
You can do this by using txtText.getText().toString().Split" ";
to return a String Array of the words separated by space. Then loop through this Array to know which word is spoken and highlight it in the TextView like this for e.g.
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