neonbjb / tortoise-tts

A multi-voice TTS system trained with an emphasis on quality
Apache License 2.0
13.08k stars 1.8k forks source link

Possible to add break in the speech? #270

Open arkilis opened 1 year ago

arkilis commented 1 year ago

Thank you for this great repo and data model. It is a GREAT work. Is that possible to manually add break. e.g. [break] in the speech output?

Thanks again!

arkilis commented 1 year ago

I tried with slow speech ref clips but the results seems not good.

s-b-repo commented 1 year ago

Yes, it is possible to add pauses or breaks in the speech output of a TTS (Text-to-Speech) program. This can be accomplished by adding appropriate markers or tags in the text input to indicate where the breaks should occur.

Here is an example of how you could add pauses in a TTS program using Python and the gTTS library:

python

from gtts import gTTS import os

text = "This is a sample text with pauses. Let's take a break after this sentence. And then we will continue."

Split the text into sentences

sentences = text.split(". ")

Generate speech output for each sentence

for i, sentence in enumerate(sentences): tts = gTTS(text=sentence, lang='en') tts.save("sentence_{}.mp3".format(i))

# Play the speech output with a pause after each sentence
os.system("mpg321 sentence_{}.mp3".format(i))
os.system("sleep 3")

In this example, the text is split into sentences using the . character as a separator. The gTTS library is then used to generate speech output for each sentence, which is saved as an MP3 file. The os.system function is used to play the speech output and to add a pause of 3 seconds after each sentence.

You can adjust the duration of the pause by changing the sleep value in the code. Note that this code assumes that you have the mpg321 player installed on your system, but you can use any other player that is compatible with your system.

arkilis commented 1 year ago

@coolst3r your solution looks like generated by ai, looks like not quite relevant to our question here.

s-b-repo commented 1 year ago

i am human and not a ai sorry if that does not help you

ktosox commented 1 year ago

@arkilis I've been messing around with interpunction and I have noticed a peculiar behaviour: adding a "-" at the end of a word tends to add a sort of pause. Though it tends to come out more like a studder.