3

This is my code that generates a audio file of what is written in variable text.

I want to take a pause between Hello and world. How can I do that ?

from gtts import gTTS
import os

text = "Hello **pause** World"
language = "en"

myobj = gTTS(text = text, lang = language, slow = False)
myobj.save("test.mp3")
#os.system("test.mp3")

I will be very thankful to you for answering my question.

1 Answers1

0

Adding a full stop between the words adds some pause:

from gtts import gTTS
import os
from playsound import playsound

text = "Hello . World"
language = "en"

myobj = gTTS(text = text, lang = language, slow = False)
myobj.save("test.mp3")
playsound("test.mp3")
#os.system("test.mp3")

Do you want the pause to be longer or be able to manipulate the duration?

If so, check out the following thread: Adding a pause in Google-text-to-speech

Eshaan Gupta
  • 614
  • 8
  • 25