Update
17 Sept 2010: Removed the tar.bz2 link from the page. Added the file as a standard zip.
Text2Audio Shell Script (BASH)
Text 2 Audio for Free! No need to pirate software, Crack Keys, or use Key Gens. If you have a computer running Linux you can convert your documents to audio files for free. It is a task that takes some time, but if you want to do it legally for free, you will find this shell script handy.
This is in no way related to the text2audio program for windows. If you are looking for them you can find them on google.
Convert from doc, rtf, pdf, ps, html, htm, chm, plain text, or even your favorate website into almost any audio format like mp3, ogg, au, wma, flac, and more for free. Using a configured Linux box, this shell script can help you automate the task of converting your files into usable audio media. Convert your Text to audio for free and do it legal! Written as a BASH shell script, connects to various gnu tools to effectively convert text to audio for free.
I have been a fan of text to speech for several years now, and have just been introduced to the HTS voices that have been released for festival (for Linux). And I love them. Yes you can tell they are electronic, but... they are good enough that you can forget they are electronic while you listen to them. (In my humble opinion).
I love to read, but given that I have 2 children under the age of 3, it makes sitting down to read books down right impossible. I discovered that I could use the festival tool text2wave to convert my texts to wav format for free. Then convert them to any other format I wanted. And then play them on my favorite portable audio player. I found doing this manually a tedious task so I wrote a bash shell script to convert multiple file types into multiple audio types.
Now, I can sit back and let my computer convert my texts to and audio format in the background while I work with other things, and when it is done I have whole books that I can play in a cd player, portable music device or mp3 player. I've been working on texts from project Gutenberg for my own enjoyment.
Dependencies
I will warn you it requires a lot of dependencies, but if you have the dependencies this should work very nicely for you. I recommend following the ubuntu forums on how to setup festival here (But only if you have ubuntu, and even then you don't have to listen to me.): http://ubuntuforums.org/showthread.php?t=751169 You must have festival installed and configured for this to work. Some of the other programs are "optional" if you don't plan on using those file types.
- bash (Pretty universal... but just in case someone didn't have it I listed it)
- festival
- lame (req for mp3 output... requires mp3 support installed too)
- sox (multi output encoding support... many types)
- libsox-fmt-all (all the available options to encode to)
- archmage (optional - chm file support)
- ps2ascii (optional - pdf file support)
- lynx (optional - chm & html file support)
- antiword (optional - doc file support)
- unrtf (optional - rtf file support)
Input
The shell script will accept any of the following input formats:
- MS Word (*.doc)
- Adobe Portable Document Format (*.pdf)
- Post Script (*. ps)
- Rich Text Format (*.rtf)
- Plain Text (*.txt)
- Hyper Text Markup Language (*.html, *htm)
- Windows Help Files (*.chm)
- As well as direct URL input so you can have a web page(s) converted to audio for you as well.
Output:
The shell script allows for conversion to any of the following types (assuming you have the correct dependencies and configuration to allow said conversions):
8svx aif aifc aiff aiffc al alsa ao au avi avr caf cdda cdr cvs cvsd dat dvms fap flac fssd gsm hcom ima ircam la lpc lpc10 lu m3u m4a mat mat4 mat5 maud mp2 mp3 mp4 mpg nist nul null ogg oss ossdsp paf pls prc pvf raw s1 s2 s3 s4 sb sd2 sds sf sl smp snd sndfile sndt sou sph sw txw u1 u2 u3 u4 ub ul uw vms voc vorbis vox w64 wav wmv wve xa xi
Usage: text2audio.sh [-l length] [-f format] [-c ON|OFF] -u [ON|OFF] [<-n url name >] [-n Name] [-a Author] -i
-l Target length in whole minutes for desired segment length
-f Output format: see below for options
-c confirm mode ON or OFF default ON
-u URL input if you are using a url as your file this should be ON [Default = OFF]
-n What to name the URL if used - Required if URL = ON; if not URL used in ID3 tag if file supports.
-a The Author of a file [Completely optional] put in file if supported.
-i the text file to input
Examples:
To convert the file "readme.txt" into ogg files that were about 10 minutes long it would look like this:
./text2audio.sh -l 10 -f ogg -n "Read Me" -a "Author's Name" -i "readme.txt"
Now, the -n and -a are not required here, however will be put into the ID3 tag of the ogg file if I include them.
To convert a website to a series of mp3's that are 5 minutes long (assuming you have the mp3 encoders installed etc.)
./text2audio.sh -l 5 -f mp3 -u ON -n "CNN's Front Page Today" -i "http://www.cnn.com/"
Now, here the -n is required and -u ON must be there to tell the script that you are sending a URL.. Otherwise it will generate an error.
Description
This takes any acceptable input text and converts it to the specified audio type with the options specified from the command line.
Extra
I included a script to batch convert a large number of files to audio from a specified directory. The script batch.sh is that tool. Use it like so:
./batch.sh
Where
Note: if you use Batch convert it does not put in a default Name or Author for the ID3 Tag, it simply leaves them blank.
License
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see
Download:
Here is a zip file containing the two scripts. Download Now!
Warning!
This is a shell script, make sure you read and understand what this script does before you run it. There is no warranty at all for this, if you run this script incorrectly it is possible to damage your computer... (ie when I ran the first version of my script it deleted my boot kernel image... I have taken steps to prevent this kind of thing from happening, but I make no guarantees.) Oh, and one last note... do not run this as root.. as a general rule running applications such as shell scripts as root is risky, so why do it...
Note to Webmasters
Q: What the heck is this "./text2audio.sh (*nix Platform; Text to Audio converter;)" I see in my web logs as a user agent?
A: Well this is the name I chose for the script as a user agent. If you see this in your web logs, that means that someone wanted to hear what you had to say... Literally. They simply connected to your site with this script and converted your content to an audio file. The computer simply read the website to the user. Be aware that the individual user is more than capable of changing this within the script, I simply created this as a courtesy so people can see who is "listening". THIS IS NOT MY WEBSITE OR NECESSARILY ME PERSONALLY" simply the software offered here that anyone (including you) can download and use under the GPL license.
Web users
If you are going to a website and find that you are being blocked when you use this script and not when you use your normal browser you have been blocked because of your user agent (how your browser identifies it self to the web server)... I do not recommend this, but you can easily change the user agent to anything you like. Simply go through the script and locate the user agent information, and modify it. In my next version of this I will probably offer the ability via a variable to change the name of the user agent if webmasters/admins become unpleasant about it.
![Validate my RSS feed [Valid RSS]](http://taggedzi.com/skin/images/valid-rss-rogers.png)
