I've always been a huge enthusiast of wearable computing; if you need any evidence, take a look at my Master's thesis, Scouter, an augmented-reality, wearable computing facial detection and recognition system. In the vein of wearable computing and ubiquitous computing, I threw together a quick application for my netbook that will use the Python feedparser module to grab one or more RSS feeds at regular intervals, and read the titles and authors of new items using the flite/festival Text-to-Speech (TTS) program. To add extra feeds, just append to the feeds array in the config options. I've tested it with a bluetooth headset and regular headphones, although I found that ALSA/PulseAudio interactions for the bluetooth headset are very finicky. I was able to solve this by creating an /etc/asound.conf file; I'd be happy to share the contents of mine.
Code:
Code:
#!/usr/bin/python
#------ Config options start here
feeds = [ "http://www.cemetech.net/forum/rss.php" ]
checkfreq = 30 #seconds
alsa_device = "pulse"
#------ Config options end here
# Import our modules!
import sys,os
import feedparser
import time
from subprocess import *
# Set up per-feed variables!
feedlatest = [""]*len(feeds);
#audio setup
aplay_args = ["aplay", "feedwav"]
if alsa_device != "":
aplay_args.append("--device="+alsa_device);
while 1:
for i in range(len(feeds)):
try:
parsed = feedparser.parse(feeds[i])
if feedlatest[i] == "":
feedlatest[i] = parsed["items"][0]["date"]
j = 0;
while j < len(parsed["items"]) and parsed["items"][j]["date"] != feedlatest[i]:
text2read = "BOL Topic: " + parsed["items"][j]["title"] + " by author " + parsed["items"][j]["author"] + ". EOL"
p1 = Popen(["flite", "-", "feedwav"], stdin=PIPE)
print "Saying '%s'" % (text2read)
p1.communicate(input=text2read)
p1.stdin.close()
p1.wait()
p2 = Popen(aplay_args,stdout=None)
p2.wait()
j+=1
#remember what we read now
feedlatest[i] = parsed["items"][0]["date"]
except:
print "Warning: failed to fetch/parse feed!"
time.sleep(checkfreq)