8

I have given a text in mytts.speak("hi hello hi",parameter,parameter...);

But the words are continuously said without any gap or pause, I want to provide some time gap between words for more clarity.

How could I achieve this ?

Lucifer
  • 29,392
  • 25
  • 90
  • 143
SMS
  • 558
  • 1
  • 9
  • 22

5 Answers5

4

If I understand your question correctly, this thread has the answer (by rushi).

Simply add a delay into the TTS queue by splitting the string and loop over the snippets via a for loop:

mytts.speak(snippet, QUEUE_ADD, null);
mytts.playSilentUtterance(2000, QUEUE_ADD, null);
Community
  • 1
  • 1
Mairyu
  • 809
  • 7
  • 24
3

Simply add a comma everywhere you want there to be pauses inserted.

For example: If you want the following web address to be said slower, enter it as a, t, t, r, s.gov

I realize this may not be suitable for some applications, but it definitely works.

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
0

This is how I put a longer pause between each word:

//initialize and declare TextToSpeech as tts

//"line" is the String you are trying to speak

char ch = '';
String temp = "";

for(int counter = 0; counter < line.length; counter++)
{
    ch = charAt(counter);
    temp = temp + ch;

    if(ch == ' ' || counter == (line.length() - 1))
    {
        tts.speak(temp, TextToSpeech.QUE_ADD, null, null);
        tts.playSilentUtterance(1000, TextToSpeech.QUEUE_ADD,null);
        temp = "";
    }

}
Joe Giusti
  • 159
  • 1
  • 3
0

Try adding '/ / / / /' to your text. It should give you it some breathing room. If you want a longer pause, try adding more.

-1

You can split you sentence in words and speak them in a for loop in a new thread. Splitting the phrase will give you a little delay, but if you want a longer one you could work on thread and make them wait. It would be something like this:

final Handler h = new Handler();
String[] words = text.split(" ");
for (final CharSequence word : words) {
    Runnable t = new Thread() {
        @Override
        public void run() {
            m_TTS.speak(word, TextToSpeech.QUEUE_ADD, null, "TTS_ID");

        }
    };
    h.postDelayed(t, 1000);
}
Giuseppe
  • 307
  • 3
  • 18
  • What is "TTS_ID"? – Nuance Oct 30 '17 at 11:52
  • It is an identifier defined by the developer. See the official https://developer.android.com/reference/android/speech/tts/TextToSpeech.html#speak(java.lang.CharSequence, int, android.os.Bundle, java.lang.String). – Giuseppe Nov 03 '17 at 14:44