Python gTTS, is there a way to change the speed of the speech

Viewed 10568

It seems that on gTTS there is no option for changing the speech of the text-to-speech apart from the slow argument.

I would like to speed up the sound by 5%. Any suggestion on how I can do it?

Best.

tts_de = gTTS("Hallo, guten tag.", lang = 'de')
tts_de.save("s.mp3")
3 Answers

This isn't actually possible. According to the offical gTTS docs, the only arguments relating to speed gTTS accepts is slow, a boolean specifying whether or not to slow down the playback.

If you're playing the file through Python, however, I'm sure there is a module that supports sped-up playback.

Ubuntu + Python + gTTS

1} Install sox

$ sudo apt-get update
$ sudo apt-get install sox
$ sudo apt-get install libsox-fmt-all

2} use the tempo 1.9 option in sox to play gTTS output 1.9 times faster

#! /usr/bin/python3.5

from gtts import gTTS
import os 

mytext='hello'

language = 'en'
myobj = gTTS(text=mytext, lang=language, slow=False)
myobj.save(mytext+".mp3")
os.system("play " + mytext + ".mp3"+" tempo 1.9")

You can set slow= False in parenthesis of gTTS and it will work. Like below.


    text = message.text
    lang = "en"
    aud = gTTS(text=text, lang=lang, slow=False tdl="co.in")
Related