Thursday, May 2, 2024
 Popular · Latest · Hot · Upcoming
23
rated 0 times [  23] [ 0]  / answers: 1 / hits: 21730  / 2 Years ago, tue, august 23, 2022, 11:34:19

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.


More From » text

 Answers
5

There's two ways of doing this; if you just want a wav file, see the first example, and for an mp3 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 valid wav file that plays correctly in any audio player.



espeak -f mytext --stdout > myaudio


Result checked with the file command (file myaudio):



myaudio: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, mono 22050 Hz


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 used ffmpeg (the git version), but you can use any program and just change the options:



espeak -f myfile --stdout | ffmpeg -i - -ar 44100 -ac 2 -ab 192k -f mp3 final.mp3


Result checked with file final.mp3:



final.mp3: Audio file with ID3 version 2.4.0, contains: MPEG ADTS, layer III, v1, 192 kbps, 44.1 kHz, Stereo

[#36024] Wednesday, August 24, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
leddre

Total Points: 180
Total Questions: 113
Total Answers: 108

Location: France
Member since Thu, Oct 27, 2022
2 Years ago
;