Search code examples
text-to-speechibm-watson

TTS Watson adding silence between sentences or words


I have been trying to add few seconds of silence between words or sentences in Watson. I tried adding a series of dots to the string but that did not seem to work, but that would be too easy. I dont see anything on the API that would help.


Solution

  • You can use SSML markup to indicate breaks. Here's an example (3s = 3 seconds):

        String text = "<speak version='1.0'>This is some text <break time='3s'/>" + 
            "This is some more text</speak>";
    

    Or you can use <break strength='weak'/> instead - there are several settings for strength=. Check out https://www.ibm.com/watson/developercloud/doc/text-to-speech/SSML.shtml

    Here's the Java SDK call you would make with the above:

    InputStream stream = service.synthesize(text, Voice.EN_MICHAEL, AudioFormat.OGG_VORBIS).execute();