RSS To Speech

Download RSS Festival Here

This is a python script which will fetch an RSS feed from a server (using FeedParser) and then read each item of news from that RSS feed aloud using Festival. This is a little pet project of mine, and the code required to make it work is incredibly short (chock full of python-y goodness.) It was developed in 2005.

This script is licensed under the LGPL.

FeedParser is a very nice RSS feed parsing library by Mark Pilgram, and Festival is a text-to-speech system by some very smart people at the University of Edinburgh. Both are freely available!

The python script allows you to run command at the command line like this:

#> python rssfestival.py slashdot newsforge

The command above goes and grabs the latest RSS feeds from slashdot.org and newsforge.com and will then proceed to read the headlines and their descriptions. You can chain feeds together like I did above and the script will read through them one at a time. You can also only give it one option to it in order to read just one feed.

The paths to the feeds and their names are stored within the python script, and adding new feeds to the program is as simple as editing the script to add in new entries. Instructions for doing this are included in the comments of the script.

This script has only been tested on Mepis Linux, which is based on Debian, but I would assume any variety of Unix/Linux will work. Probably won’t work on Windows, as it uses Unix/Linux commands and I cannot find a Windows port of Festival. Sorry.

The following feeds are included by default:

  • Slashdot.org (command line name: slashdot)
  • Newsforge.com (command line name: newsforge)
  • MSNBC.com (command line name: msnbc)

See below as to why other feeds were not included in the script by default.

Installation

These installation instructions are made for Debian, or at least any distro which includes the apt-get program and its repositories. To install these programs without apt-get, follow the individual installation instructions for each library.

1. Install Python if it is not already installed:

#> apt-get install python2.4

2. Install Python’s dev packages:

#> apt-get install python2.4-dev

Note: If python is already installed, but it’s version 2.3 and you didn’t download 2.4:

#> apt-get install python2.3-dev

3. Download and install FeedParser from http://www.feedparser.org, following the instructions there for installation. (very simple)

4. Install Festival Text-To-Speech system:

#> apt-get install festival

5. Test Festival

#> echo ‘this is a test of the festival text-to-speech system!’ | festival -tts

6. Download the RSS Text To Speech: rssfestival.zip

7. Extract the zip and execute the script with python!

Using the Script

The script takes command line arguments as to what feed you wish to be read aloud. The command-line names available are defined within the script, and adding new feeds is very easy. The script must be invoked through the command line like this:

#> python rssfestival.py <feeds to parse>

If no feeds are supplied then the script will state an error message. If there are any problems parsing feeds it will also let you know.

Adding Feeds To Parse

Adding feeds to RSSFestival is pretty easy. Just open up the rssfestival.py script, and find the section a few lines down from the top that explains adding feeds. Then just add in a new line for a new feed like so:

feeds['<command-line name>'] = (‘<Readable Name>’, ‘<RSS URL>’)

Command line name is the name of the feed on the command line. If you put ‘myfeed’ here, then typing:

#> python rssfestival.py myfeed

Will parse the feed at the RSS URL supplied. Readable name is a readable version of the name of the feed; the script will actually read this name aloud when it begins to parse.

Why are no mainstream news outlets (other than msnbc) included by default?

Three letters: TOS. I was planning to include Fox News and CNN feeds with this script, but upon examining their terms of service I saw that it is against their terms to write an RSS reader which does not supply links to their main page for each story. As there is no GUI in this and no way to included a clickable link, they are not included in the script. Perhaps a future version of this script will include them. I did not find such terms on the three feeds included by default.

There is nothing stopping you from adding them in manually, however

Leave a Reply