I'd like to convert an text file to an mp3 file using espeak. Is it possible to do this? I'm trying to use espeak to create a song synthesis shell script that can convert text to a song.
I'd like to convert an text file to an mp3 file using espeak. Is it possible to do this? I'm trying to use espeak to create a song synthesis shell script that can convert text to a song.
There's two ways of doing this; if you just want a
wav
file, see the first example, and for anmp3
conversion see the second.1) Feed
espeak
your text file using the-f
option, then use the--stdout
option and redirect its data stream to file to create a validwav
file that plays correctly in any audio player.Result checked with the
file
command (file myaudio
):2) If you want an mp3 conversion you will have to use a program to convert your file (or simply save it in
audacity
and export it as mp3). I have usedffmpeg
(the git version), but you can use any program and just change the options:Result checked with
file final.mp3
:I actually wrote a script achieving this... and it ended up working quite well.
https://github.com/divVerent/ecantorix
Example: https://github.com/downloads/divVerent/ecantorix/sarastro.ogg
espeak now has a -w option which outputs to wav
(It still would need to be converted to mp3 afterwards.)
The
--stdout
option to espeak will tell it to write the audio data to stdout instead of putting it through the audio device. From there you can pipe it into e.g. ffmpeg for conversion to the proper format.