Convert text files to MP3 under Linux
First we would need to install festival. We can install festival with the following command :
sudo apt-get install festival
Now we need to install voices which would be used to dictate the text (install any one of the following ) :
To install British Accented male voice issue the following command :
sudo apt-get install festvox-rablpc16k
To install American Accented male voice issue the following command:
sudo apt-get install festival festvox-kallpc16k
Now once you have installed festival and voice package we are ready to convert text files .wav files .
Lets say you want computer to read file named kaddu.txt you would need to pipe(send output of one command to other ) the cat command to festival. You can do so by issuing the following command :
cat -A kaddu.txt | festival --ttsNow instead if you want to convert kaddu.txt to kaddu.wav you can do so by piping the output of cat to a tool that comes with festival text2wave. You can do so by issuing the following command in the terminal window :
cat -A kaddu.txt | text2wave -o kaddu.wavNow however if you want to remove special characters and want festival/text2wav to read only a to z,A to Z, space, “,”,”.”,”!”,”?”. You can do so by piping the output of cat to sed and then piping the output of sed to text2wav/festival.
cat kaddu.txt |sed 's/[^a-zA-Z .,!?]//g'|festival --tts
or
cat kaddu.txt|sed 's/[^a-zA-Z .,!?]//g'|text2wave -o kaddu.wavNow the (.wav) file produced is uncompressed and are huge in size so you might like to convert it to mp3 to reduce it's size and to allow the files to be played on iPod or any other mp3 player. You can convert .wav files easily to (.mp3) file format by using lame .
To install lame issue the following command in the terminal window :
sudo apt-get install lameafter istallation is over to convert say kaddu.wav to kaddu.mp3 issue the following command :
lame -f kaddu.wav kaddu.mp3NOTE : I am using -f switch here which basically encodes mp3 file faster and in lower quality .
Article Written by : Ambuj Varshney (blogambuj@gmail.com)
For Desktop on Linux Blog , http://linuxondesktop.blogspot.com
(C) 2008 , Ambuj Varshney
Thank you very much for this post! It's the first one I've found on this topic. It's very descriptive and excellent too. Especially for your sed example. Plus the regular expression command line parsing in general. That saves a ton of wonder and difficult work, with a simple simple and now obvious fix (that I wouldn't have thought of, actually. I would have probably cleaned up text file to input by PHP..importing it clean. maybe this is better).
ReplyDeleteAnyway. Do you have more on this topic? My email is matt at mattkaufman dot dot dot or comma whatever they use (dot) org
SUPER HELPFUL THANK YOU. I CAN STUDY IN PEACE.
ReplyDeleteThanks for this post now I can study in the car.
ReplyDeleteExcellent and very descriptive posting. Thanks for taking the time to create it. It was most helpful.
ReplyDeleteKeep it up!
ReplyDelete