SRT to speech: turn subtitles into a voice track
A subtitle file already holds everything a voice-over needs: the words and the moment each line should be heard. Turning it into speech gives a tutorial, a short or a translated video a voice track that lines up with the picture, without recording a single line.
The free SuperClonica engine voices each cue offline with a natural voice, and a short Python script places it at its start time. This guide shows the script, how to fit long lines into their slots and how to put the track under the video.
What you need
The engine does not read SRT files by itself: about twenty lines of Python do the job.
- An SRT file: from your editor, from automatic captions or a translation.
- The free SuperClonica engine and Python 3.10 or newer: python -m pip install superclonica-cpu. numpy comes with it.
- A voice: one of the ten stock voices, a catalog voice or your own trained voice.
- No graphics card: an ordinary processor is enough.
Hear a line free online
On the page of any voice, paste one subtitle line, 30 to 100 characters, choose the language and press Voice it. In a few seconds you hear how the video will sound, with no account.
From cues to one track
Create the engine once before the loop: loading takes a few seconds, each line a fraction of a second.
- Read the file: each cue is a number, a line with start and end times, and the text.
- Voice each cue: audio, sample_rate = tts.synthesize(text, voice="F2", lang="en", seed=7).
- Create a silent numpy array as long as the video and add each line at the sample where its cue starts: start time in seconds times the sample rate.
- Save the result with tts.save("track.wav", track).
Lines that do not fit
Print the length of each spoken line next to the length of its cue. When speech runs longer than its slot, it overlaps the next line. Shorten the text first; merge two short cues into one; or create the engine a little faster, for example Superclonica(speed=1.15), within the allowed 0.7 to 2.0. The same text, voice and seed always give the same audio, so you can fix one line and rebuild the track.
Put the voice under the video
Import track.wav into your video editor as an audio track, or join it with the video in one command: ffmpeg -i video.mp4 -i track.wav -map 0:v -map 1:a -c:v copy -c:a aac voiced.mp4. Keep the original sound on a second track if you want music or effects under the voice. Voice only videos you made or have permission to voice, and do not use a voice that imitates a real person without consent.