I came up with the idea to use a good 'ole Raspberry Pi and I figured there must be some way to go on the internet, grab the appropriate TV schedule and then read it out through an amplified speaker, I decided that I also needed an easy to use and chunky control system, finally all of this would need to be in a nice enclosure.


Software Overview :-

I spent some time in a famous search engine and came across a couple of web services (and some inspiration from a couple of other projects) that would allow me to make my dream a reality!

I found a web service called "Atlas" which is provided by a UK company called Metabroadcast, it allows you to make a formatted request and then returns JSON formatted schedule data, another request then retrieves the appropriate content JSON data.

http://atlas.metabroadcast.com/#apiExplorer

So, given that I could get the content title, description, showing times etc. for a particular channel I figured all I needed to do now was get a text to speech service to read my formatted text aloud, I did look at some open source TTS programs for the RPi but then realised that I could just use the free Google Translate service to do the talking for me.

I've never written Python before but I'm a developer anyway so with a bit of web-reading I was able to cobble something together, it uses an SQLite database to store the settings and the JSON data that is retrieved from Atlas (I know storing JSON data in a database isn't exactly cool but it was easier for this purpose).

This JSON data is then parsed and a text phrase is sent to Google Translate. The audio from Google Translate is in turn saved as an MP3 and played using mpg123. I actually "cache" the audio files (I give them a unique filename and look for them before going to Google Translate) so that the system isn't constantly going online to get the phrase audio if it already exists.

All of this is controlled by the action of a keypress, when my main loop sees the number 1 it executes one function, when it sees number 2 it executes another etc. etc.

I came across a couple of projects that helped me to write the code for this project I've linked to them below and offer my heartfelt thanks to the authors for sharing their knowledge!


Hardware :-

- The CPU

  • Raspberry Pi Model B
  • 4 port USB hub that acts as a power supply to the RPi
  • Speaker
  • Mini 5v amplifier (ebay)
  • Basic USB soundcard
  • Wifi dongle

- The Controller

  • USB keyboard control board
  • Arcade joystick
  • Arcade buttons

To make the controller I took apart a USB keyboard and then used my meter (and eyes/patience) to follow the membrane traces back to the control board, by doing this I could deduce which 2 wires needed to be connected together to press a particular key. These were then in turn soldered to a button and mounted in a plastic enclosure.

I won't go into the construction it's pretty self-explanatory from the pictures and youtube video!


Linux Prerequisites :-

The following linux packages must be installed :-

sudo apt-get install python-pip
sudo apt-get install mpg123
sudo apt-get install ffmpeg
sudo pip install simplejson
sudo pip install python-dateutil
sudo apt-get install sqlite3

Folder Structure :-

The python files must be placed within a folder the path to which is set in the "EVA.py" script and is then passed as a parameter to the various functions, there must also be the following subfolders within the main folder :-

  • \audio\content
  • \audio\general
  • \audio\schedule
  • \data

SQLite Database :-

You must create an SQLite database in the \data folder called "atlasdata.db" the table structures are as such :-

settings (settingid TEXT, settingvalue TEXT)

schedulelist (scheduleid TEXT, scheduletitle TEXT, scheduletype TEXT, listorder INTEGER, selected INTEGER)

timelist (timeid TEXT, timetitle TEXT, selected INTEGER)

daylist (dayid TEXT, daytitle TEXT, selected INTEGER)

These can be created from the SQLite command line.


Code :-

I got my inspiration for the Google Translate code from these 2 projects and would very much like to thank the authors -

http://www.daveconroy.com/turn-raspberry-pi-translator-speech-recognition-playback-60-languages/...

Read more »