This Python script leverages the gTTS API to transform SRT (SubRip Subtitle) files into spoken audio. Beyond simple conversion, the script incorporates intelligent speed adjustments, ensuring that the synthesized speech aligns closely with the pacing of the original speaker for a more natural and synchronized playback experience.
- gtts
- pydub
- tqdm
-
Clone the repository:
git clone https://github.com/JimChr-R4GN4R/subtitles-to-speech cd srt-to-speech
-
Install the required dependencies:
python3 -m pip install gtts pydub tqdm
Run the script with the following command:
python3 srt_to_speech.py srt_file output_file language_code
srt_file: Path to the SRT file.
output_file: Output filename.
language_code: Language code for text-to-speech.
python3 srt_to_speech.py example.srt output.wav en