gTTS icon indicating copy to clipboard operation
gTTS copied to clipboard

Add ability to adjust speed

Open KonerDev opened this issue 1 year ago • 4 comments

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?

KonerDev avatar Jun 24 '23 06:06 KonerDev

speed will be a nice feature, Is there a way to give pause in the sentence?

hanzigs avatar Aug 20 '23 23:08 hanzigs

still needs the feature.

ILG2021 avatar Aug 29 '23 01:08 ILG2021

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.

pndurette avatar Sep 27 '23 17:09 pndurette

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)

ILG2021 avatar Sep 28 '23 06:09 ILG2021