Pi - the News Reader
This is a project based on Raspberry Pi. It is a 'bot' which goes to the internet to fetch news headlines and reads them for you. It also uses a voice recognition system to interact with you.
See the Project in Action
Complete Tutorial
News Site - http://www.ndtv.com/article/list/top-stories/
Voicecommand Tutorials: http://stevenhickson.blogspot.in/2013/06/voice-co...
news.py (for indentation of the for loops, look at my code in the video)
*******************************************************************************************
import subprocess
import requests
from bs4 import BeautifulSoup
import textwrap
head = 'mpg123 -q ' tail = ' &'
url = "http://www.ndtv.com/article/list/top-stories/?pfrom=home-lateststories"
r = requests.get(url)
soup = BeautifulSoup(r.content)
g_data = soup.find_all("div",{"class":"nstory_intro"})
for item in g_data:
shorts = textwrap.wrap(item.text, 100)
for sentence in shorts:
sendthis = sentence.join(['"http://translate.google.com/translate_tts?tl=en&q=', '"'])
print(head + sendthis + tail)
print subprocess.check_output (head + sendthis + tail, shell=True)