Skip to main content

Convert text files to MP3 under Linux

Even though I am not a fan of audio books and the only thing I use my iPod for is listening music still while exploring Festival(which is basically a General multi-lingual speech synthesis system) I found out that it's very easy to convert normal text files into mp3 using festival . Now this could be especially useful for people who either listen to audio books or people who have difficulty in reading.

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 --tts
Now 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.wav
Now 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.wav
Now 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 lame
after istallation is over to convert say kaddu.wav to kaddu.mp3 issue the following command :
lame -f kaddu.wav kaddu.mp3
NOTE : 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

Comments

  1. 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).

    Anyway. Do you have more on this topic? My email is matt at mattkaufman dot dot dot or comma whatever they use (dot) org

    ReplyDelete
  2. Anonymous7:53 AM

    SUPER HELPFUL THANK YOU. I CAN STUDY IN PEACE.

    ReplyDelete
  3. Thanks for this post now I can study in the car.

    ReplyDelete
  4. Anonymous7:19 PM

    Excellent and very descriptive posting. Thanks for taking the time to create it. It was most helpful.

    ReplyDelete

Post a Comment

Popular posts from this blog

13 Things to do immediately after installing Ubuntu

In this article i describe some of the things to do immediately after installing ubuntu on your machine . Since most of the people reading this would be shifting from Windows to Linux with a system dual booting so i would focus more on making transition easy from Windows to Linux.

Creating Your ultimate Ubuntu 7.10 Desktop

Ubuntu 7.10 Codenamed Gusty Gibbon was released few weeks back with much fanfare ,now Ubuntu for past couple of years has been one of the most popular Desktop Linux distributions . Ubuntu 7.10 includes a number of features , applets and Wizards to simplify desktop Linux experience however because of many licensing restrictions it does not include out of the box support for popular audio/video codecs and many commercial but good applications . Also because of the limitation of trying to accommodate all kind of applications on single CD Ubuntu comes with a limited set of applications .

Now , i often have arguments with my friends who are new to computers that windows is…

Over 16 Small Games For Ubuntu Linux

Over 16 Small Games For Ubuntu Linux

Ubuntu Linux is one of the most popular Linux distribution , it is especially popular among Linux newbies and windows refuges . Now Ubuntu Linux does come with a descent set of applications , still there is a scope for including some more quality applications and especially games . Now in this tutorial i will show you how to install a large number of small , easy and less resource hungry games on Ubuntu Linux with screen-shots of games .


1. Rocks 'n' Diamonds

Rocks 'n' Diamonds is a Boulderd*sh game for X11 with more than just the falling rocks and diamonds of its namesake. The object is still to collect all the diamonds (and emeralds), then get to the exit before time runs out. But your character must make use of bombs, spaceships, and many other elements in order to fill his quota of jewels.

Installation : -

Type the following command in the terminal window

wget http://www.artsoft.org/RELEASES/unix/rocksndiamonds/rocksndiamonds-3.2…

Making Music(Beats) on Linux/Ubuntu with Hydrogen

I am going to review a couple of Music Making Softwares for Linux and am starting with the simplest and one of the best!HYDROGEN. Hydrogen basically is a pattern based drum programming software which in layman terms means, it allows you to make your own beats.And in case you aren't much into music, you might be wondering “what the hell will i do with this piece of software”...well here is a word from my friends who've tried this: “Its pretty fun playing with this software, n even without knowing much, you could actually MAKE SUM MUSIC!!!”

There was this software called Acoustica Beatcraft(for windows) which actually introduced me to this beat making stuff and I was quite interested, but sadly it was too costly for me to buy it. So i was stuck using the trial version of the software and sadly as soon as i got the grip of the software the trial expired, and so my search began for software which would do the stuff for me and luckily i found this amazing piece of software HY…