How to Give Pause or Gap Between Words in Tts in Android

How to pause android.speech.tts.TextToSpeech?

The TTS SDK doesn't have any pause functionality that I know of. But you could use synthesizeToFile() to create an audio file that contains the TTS output. Then, you would use a MediaPlayer object to play, pause, and stop playing the file. Depending on how long the text string is, it might take a little longer for audio to be produced because the synthesizeToFile() function would have to complete the entire file before you could play it, but this delay should be acceptable for most applications.

How to insert pause in speech synthesis with grammatical hints

Just insert

<silence msec="5000" />

in the text for 5 sec waiting (Source).

Disclaimer: This code works only in an appropriate user agent.

// code taken from https://richjenks.com/dev/speechsynthesis/var utterance  = new SpeechSynthesisUtterance(),    speak      = document.getElementById("speak"),    text       = document.getElementById("text");
// Delay links and events because speechSynthesis is funnyspeechSynthesis.getVoices();setTimeout(function () { // Add event listeners var voiceLinks = document.querySelectorAll(".voice"); for (var i = 0; i < voiceLinks.length; i++) { voiceLinks[i].addEventListener("click", function (event) { utterance.voice = speechSynthesis.getVoices()[this.dataset.voice]; }); }}, 100);
// Say text when button is clickedspeak.addEventListener("click", function (event) { utterance.text = text.value; speechSynthesis.speak(utterance);});
<textarea id="text" rows="5" cols="50">Hi <silence msec="2000" /> Flash!</textarea><br><button id="speak">Speak</button>


Related Topics



Leave a reply



Submit