bnsantoso / sub-to-audio

Subtitle to audio, generate audio from any subtitle file using Coqui-ai TTS and synchronize the audio timing according to subtitle time.
https://pypi.org/project/subtoaudio/
Mozilla Public License 2.0
104 stars 13 forks source link

option to speed up the voice? #2

Closed reishikin closed 1 year ago

reishikin commented 1 year ago

Hey there, thank you for sharing the fantastic script! I was wondering if you could help me find a way to speed up the voices a bit, maybe to around 1.4 times their current reading speed?

The problem is my subtitle has 2 hours duration, however when I tried to read the subtitle with the default model and speed, the final wav would have 3 hours duration and therefore, it can't be used for voice over videos.

Add option to speed up the voices and then join them (not the other way around) could be really helpful. Otherwise, any advice or solution to fine-tune the process would be highly appreciated!

bnsantoso commented 1 year ago

As far as I know, Coqui AI TTS doesn't have an option to control speech rate, so the only way to speed up the audio without causing pitch shifting is by using ffmpeg. Actually, I already planned this for a future update, with two modes of speed up. The first one is to speed up the entire audio at the same speed before join them, and the second is to only speed up the audio that doesn't match the subtitle duration. The second one will probably be weird since the speech rate consistency will vary.

So, for now, the only way is to edit your audio manually while waiting for me to add the speed-up feature.

bnsantoso commented 1 year ago

Hi, the new update has been released now. You can now control the speech rate or tempo. You can use the argument tempo_mode='all' to affect all audio speed and tempo_speed='1.4' to specify the speed. The other mode is tempo_mode='overflow', which affects only audio that doesn't match the subtitle duration, and you can use tempo_limit='1.2' to limit the tempo change in overflow mode.

You can update package from git for new version.

reishikin commented 1 year ago

thank you so much for your hard work! I want to donate for you, could you open kofi for donation?

bnsantoso commented 1 year ago

Thank you very much for the donation I appreciate it, bless you