7

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")
J_yang
  • 2,672
  • 8
  • 32
  • 61

3 Answers3

4

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.

4

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")
conor
  • 1,131
  • 1
  • 15
  • 20
0

You can use pydub package to speed up your audio.

from pydub import AudioSegment

audio = AudioSegment.from_file("test.mp3", format="mp3")
# or
audio = AudioSegment.from_mp3("test.mp3")
        
audio.speedup(playback_speed=2.0) # speed up by 2x
    
# export to mp3
final.export("final.mp3", format="mp3")
Buddhika
  • 116
  • 2
  • 10