gTTS
gTTS copied to clipboard
Add ability to adjust speed
Prerequisites
- [x] Did you make sure a similar issue didn't exist?
- [x] Did you update gTTS to the latest? (
pip install --upgrade gTTS
)
Proposed Behaviour
I suggest adding a feature that allows users to modify the speed of the tts output.
tts = gTTS(text='Hello World!', lang='en', speed=2.1)
tts.save(name)
Context
There is currently no way to make the speed particularly fast. Can you please add that?
speed will be a nice feature, Is there a way to give pause in the sentence?
still needs the feature.
Google Translate only has two arbitrary speech speed options ("normal" and "slow"), to modify the speed, gTTS would need to tap into some sound libraries, which it currently leaves to the developer.
I don't think I'd want to add it in (unless I add some extra optional dependancies, perhaps), but I could eventually provide examples of how achieve it, TBD. Will put this documentation.
I have implement it by ffmpeg:
output_audio_file = "output_audio.mp3"
ffmpeg_command = ["ffmpeg", "-y", "-i", temp_audio_file, "-filter:a", "atempo=1.3", output_audio_file]
subprocess.run(ffmpeg_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)