Introduction: Speaking Assistant(Edison Edition)

Picture of Speaking Assistant(Edison Edition)

Internet is filled with all kinds of useful information. We are going to build a gadget in this Instructuble using Intel Edison that you can easily use to gather the information and speak out the information using TTS (text to speech synthesis software).

The information available on Internet is aggregated into what is known as RSS feed which stands for Rich Site Summary/Really simple syndication.

This web technology is used to update frequently changing information such as News, Stock price, weather etc... Let's say you need to know the stock price of a corporation. There are plenty of web services that update this particular information and each service provider assigns an unique address for the stock price of your favorite corporation when you access this address, as a response you get the current stock price (with some added meta data). For user input, we are going to use an infrared proximity sensor such as this one to detect the user action and to determine what information the user wants from the Internet.

How does it work? The main interface between the user and the device is an IR proximity sensor. These sensors get triggered whenever some obstacle is placed in front of the sensor. Various operations are triggered depending on number of times the sensor is triggered (operations are configurable). Here are the features:

  • Reads out the RSS feeds
  • Displays number of unread emails in inbox (gmail only)
  • Changes LCD back light depending on number of unread emails in inbox
  • Reads out temperature
  • Reads out emails (sender and subject)
  • Control digital pins.

Have a look at the attached video to see the above features in actions. For TTS, espeak will be used. We will also need an USB sound card which when connected to a speaker, will speak out the information.

This is same as this project done on Galileo.

Step 1: Installing the Required Packages

We need to have access to the Edison console to install packages have a look at this post to know how you can do that.

The packages that we need are on different server than the default one. We need to add additional repository.

Add additional repos by editing the base-feeds.conf file using vi

vi /etc/opkg/base-feeds.conf

hit 'i' to start editing the file and paste the following lines

src/gz all http://repo.opkg.net/edison/repo/all
src/gz edison http://repo.opkg.net/edison/repo/edison src/gz core2-32 http://repo.opkg.net/edison/repo/core2-32

Then press 'Esc' key and then ":wq" to save the file and exit.

Install the espeak using following commands:

opkg update

opkg install espeak

Next, we need to install python packages for parsing the RSS feeds and managing the gmail account related features.

But before that, we will need to boot strap setup utilities in python so that we can install Python libraries. Following steps will install python setup tools and "pip" onto your Edison.

wget     http://peak.telecommunity.com/dist/ez_setup.py
python ez_setup.py
easy_install pip

Install feedparser with following command

pip install feedparser

Next, we need to install GMail for python

wget --no-check-certificate https://github.com/charlierguo/gmail/archive/master.zip
unzip master.zip
cd gmail-master
python setup.py install

cd

Step 2: Making Hardware Connections

Picture of Making Hardware Connections

For this step, you'll need following things

  1. Grove Kit base shield
  2. Grove kit LCD
  3. Grove kit LED (optional)
  4. Grove kit temperature
  5. sensor IR proximity sensor

Make the following connections:

  • LCD - I2C0
  • LED-D4
  • Temperature sensor-A1
  • IR proximity sensor
    • Vcc/5v to 5V on Edison(via base shield) header
    • Gnd to any of the GND on Galileo header
    • Output to D7 on Edison(via base shield) header

To connect any USB device, to the USB host port of the base board, you'll need to move the switch near the USB port towards the USB host port as in the attached picture. In this mode, you will have to power the base board with a DC power supply adapter (7V-15V, I used the power adapter that came with Intel Galileo Gen2) .

You can connect the USB audio card directly to the Edison USB port but I recommend using an externally powered USB hub to connect the audio card for better performance.

Step 3: Configuring the System

Picture of Configuring the System

In this step you'll learn to personalize the system.

Download "SpeakingAssistant.zip" and extract the contents of the archive into a folder "SpeakingAssistant".

All of the configuration information is stored in the file "configuration.py" as Python variables.

Open "configuration.py" if you want to configure any of the below parameters.

There are six variables that you can configure.

The first among them is "operations" "operations" is a list of tuples.

The first tuple in the list, in our case is "RSS" defines what action to take when the IR proximity sensor is triggered once. Similarly, subsequent elements define what action is to be performed when IR proximity sensor is triggered as many times.

Currently following operations are defined:

  • RSS
    • You define this operation using "RSS" tag. Triggering this operation will cause the app to fetch the RSS and speak it out
    • First element shall be "RSS" followed by RSS feed address specified in quotes and that is to be followed by content within the feed that you are interested in
    • ex: ("RSS", "http://www.moneycontrol.com/rss/MCtopnews.xml", "title")
  • Temperature:
    • Reads out temperature using the Grove temperature sensor connected to one of the analog pins and displays the same on the LCD
    • First element will be "Temperature" followed by the analog in pin. In below example analog pin would be 1
    • ex:("Temperature", 1)
  • Mail:
    • Reads out the mail in gmail inbox and displays the sender and subject on LCD
    • First element should be "Mail" followed by a dummy argument (meant to ease parsing)
    • ex: ("Mail", "0")
  • GPIO:
    • Controls a GPIO(digital) pin. You can connect a relay to control other devices
    • First element will be "gpio" followed by "on" or "off" indicating the digital pin has to be turned on or off respectively. The last element will be the digital pin 4, in the below example
    • ex: ("gpio", "on", 4)

Next in the configuration file is senders list. This list will be used by the mail thread to fetch only unread emails in inbox from the senders listed in the list. If left empty, all the unread mails will be fetched.

ex: senders = ['navin.bhaskar.5@gmail.com',]

"unreadMailCnt" controls the color of LCDs backlight depending on the number of unread mails in the inbox. As the number of unread mails approaches value of "unreadMailCnt", the LCD backlight starts to turn red from green.

ex: unreadMailCnt = 50

"ttsSpeed" let's you control the speed with which the text will be spoken.

ex: ttsSpeed = 150

Use "mailCredentials" to configure the gmail login details.

ex: mailCredentials = {'userName':"thismail@gmail.com", 'pwd':"password"}

Replace 'thismail@gmail.com' and 'password' with your account details.

Lastly, we have the option to set the sound card. To know the sound card number, enter the following command:

aplay -l

Note down the number that appears after "card " in front "USB device" sound card. That would be 2 in the attached screenshot. Hence the variable soundCard is set as 2.

Step 4: Configuring the RSS

While all configuration parameters are easy to configure except for the RSS hence this step. This step is to help you configure the RSS feed.

In this step I'll walk through one example for getting the information that you need from the feed. Let's say I am interested in knowing the whether of Bengaluru. The first thing to do is google "Bengaluru weather RSS feed" select any of the site and look for the "RSS" logo and right click on it and "copy link location". Paste this link in the configuration file in place of feed parser address. In place of content of interest, you can try 'title' or 'summary' or 'summary_detail' make a few trails and decide what suits best for you. With all these information in hand, the config parameter would be some thing like this: ("RSS", "http://in.weather.com/rss-INXX0012", "summary") Similarly you can construct configuration for news, stock prize etc.

Step 5: Using the Application

Picture of Using the Application

To enable gmail related features on the device, log in to your gmail account from your browser click on "My account"->"sign-in and security" and scroll down till you find option "Allow less secure apps: off" and then toggle it to "on"

Now is the time to get the Python script to be copied onto the Edison. The folder created from the zip file you downloaded, extracted and modified in step 3 has to be copied onto a USB drive. Connect the USB drive to USB port on base board (or alternatively, use methods listed in this post and this to transfer the folder using SSH). In console of Edison, type following command

mount /dev/sda1 /mnt
cp -r /mnt/SpeakingAssistant /home/root/ 
 cd /home/root/SpeakingAssistant
umount /dev/sda1

Remove USB drive.
Connect the USB audio card to the Galileo (preferably via an externally powered USB hub for better audio performance). Connect speakers to USB card.

Run the application using following set of commands

cd  /home/root/SpeakingAssistant<br>
python App.py # or do 'chmod +x App.py && ./App.py'

To exit the app any time, press 'ctrl+c'.
You can also configure the application to run automatically using cron.

Comments

edwallace (author)2016-05-12

Thumbs up very nice

PawelR (author)2015-08-13

The repos for espeak are incorrect. Should be

src/gz all-2 http://repo.opkg.net/edison/repo/all

src/gz edison http://repo.opkg.net/edison/repo/edison

src/gz core2-32 http://repo.opkg.net/edison/repo/core2-32

NavinB (author)PawelR2015-08-21

Thanks for pointing out the mistake. I've corrected it now.

About This Instructable

2,817views

74favorites

More by NavinB:Random news reader on the Linkit smart 7688Effecter: A simple guitar effects processorGuitar Tuner
Add instructable to: