Wednesday 16 September 2015

DIY Guide to answering Ganesha

This project is about using Raspberry pi with USB microphone and Speaker for interactive answering machine. We are calling it Talking Ganesha. In Hindu Culture , God Ganesha is called as God of Knowledge. We have created this project just to create Talking Ganesha in Ganesh Festival. We have usedGoogle Speech API for converting speech to text, WolfarmAlpha API for answering questions and then eSpeak to speak out the answer return by WolframAlpha.
It is based on initial work done by Mr Dave. His instruction can be found in "http://makezine.com/projects/universal-translator/.
This project was developed with the help of Utsav (my Infosys team mate) and Suhas (Vigyan Ashram Fab Lab Instructor)
You need following hardware :
1. Raspberry Pi B+
2. Sound Card (In case you don't have USB headphone or USB Mic + Speaker)
3. Headphone or Mic + Speaker with audio jack
4. Internet Connection
https://youtu.be/Ofez1F3VLAE

Step 1: Set up Raspberry Pi

Picture of Set up Raspberry Pi
(This is taken from step 1 of Universal Translator "http://makezine.com/projects/universal-translator/)
Assuming you have Raspbian installed on your Raspberry Pi.
Update the software on your Raspberry Pi: sudo apt-get update sudo apt-get upgrade
Install the software required for this project with following commands:
sudo apt-get install python-pip mplayer flac python2.7-dev libcurl4-gnutls-dev
# To get object via any HTTP request e.g. calling Speech API from python script
sudo pip install requests pycurl
# To get answers for your questions
sudo pip install wolframalpha
# To manage sound / audio devices
sudo apt-get install alsa-utils
# To convert text to speach
sudo apt-get install espeak
# We shall use google Speech API to convert Speech to Text

Step 2: Create Google Sppech API Key and Wolfram API Key

Picture of Create Google Sppech API Key and Wolfram API Key
GoogleSpeechAPI.jpg
Download required python and shell scripts.
Create new folder called "Talking Ganesha" inside home folder
Download the following scripts from download section :
text-to-translate.py
queryProcess.py
stt.sh
Execute command on Raspberry Pi
sudo chmod +x stt.sh
Google Speech API Key :
Use instructions from http://makezine.com/projects/universal-translator (Step 4).
This google api key shall be used in script "text-to-translate.py (key='GoogleKey')
For Wolfram Key :
Sign Up
Complete Form to activate your account
Click on Get an AppID button on right
Enter application Name and Description
Now copy APPID.
This key shall be used in script "queryProcess.py" (app_id = "WolframAlpha Key")
Note that you can make 50 calls to Google Speech API (per day) and 2000 calls to Wolfram Alpha API (Per month). And this usage must be restricted to personal use (non commercial).

Step 3: Set up Audio Devices (USB Sound Card)

Picture of Set up Audio Devices (USB Sound Card)
Headphone.jpg
This is taken from step 2 of Universal Translator "http://makezine.com/projects/universal-translator/...
Plug in the USB headset (use a powered USB hub, if necessary).
Run the following commands, which will list your sound devices: cat /proc/asound/cards cat /proc/asound/modules
You should see that the Headset is listed as card 1. The second command should show that the driver for card 0 (the default output) is snd_bcm2835, which is the Raspberry Pi's analog audio output. The driver for card 1 (our Headset) is snd_usb_audio. If you don't see the headset listed, try rebooting: sudo reboot In order to set the USB headset as the default for both audio input and output, you'll need to update the ALSA configuration file. Open it in the text editor nano:
sudo nano /etc/modprobe.d/alsa-base.conf
Change the line that says:
options snd-usb-audio index=-2
to:
options snd-usb-audio index=0
Save and close the file with Ctrl-X and typing y. Reboot the Raspberry Pi using the following command:
sudo reboot
After the reboot, the sound system should be reloaded so that when you run the above commands
cat /proc/asound/cards
cat /proc/asound/modules
again, you should see the USB Headset is now the default input/output device (card 0) as shown above
Test it out by recording a 5 second clip from the microphone:
arecord -d 5 -r 48000 ganesha.wav
Play it back through the headphone speakers:
aplay ganesha.wav
To adjust the levels you can use the built-in utility alsamixer. This tool handles both audio input and output levels.
sudo alsamixer

Step 4: Ganesha starts answering

Use following command :
sudo python text-to-translate.py
Now you shall listen sound "Please ask me any question now" You can ask question in 5 seconds......wait for some time then it shall give you answer.
Wait till you listen "Please ask me any question now " statement again to ask another question.
Ganesha shall keep continuing till user press (Ctrl +Z) to halt the script.
You can change the length of time it shall wait to listen to question by updating -t parameter in stt.sh script.
For ,ore Information Regarding it Visit Instructables.com


Japan To Help Modernise Indian Railways

Japan has agreed to modernise railway stations across the country while participating in Indian Railways' $140 billion (Rs 930650 crore) investment plan over the next five years. 

A Japanese delegation will soon visit India to study the opportunities for industries in the railway station development plan of railways as the public transporter has identified 400 stations to be upgraded in private investment, an official release said here today.
Participation of Japanese railways and Japanese companies in various areas of Indian Railways with the aim of modernisation and technology upgradation was also emphasised in the discussions. While agreeing for cooperation on modernisation and upgradation, Japan has agreed to assist the public transporter in achieving its zero-accident mission. 



Japan has agreed to modernise railway stations across the country while participating in Indian Railways' $140 billion (Rs 930650 crore) investment plan over the next five years. 
image
wikimedia
A Japanese delegation will soon visit India to study the opportunities for industries in the railway station development plan of railways as the public transporter has identified 400 stations to be upgraded in private investment, an official release said here today.
Railway Minister Suresh Prabhu, who is in Japan to strengthen cooperation in rail sector, held a series of high-level meetings with Japanese Prime Minister Shinzo Abe, Deputy Prime Minister and Finance Minister Taro Aso among other ministers and senior officials and has highlighted that the Indian public transporter would be the next major destination for infrastructure investment worth $140 billion, it said.
image
Participation of Japanese railways and Japanese companies in various areas of Indian Railways with the aim of modernisation and technology upgradation was also emphasised in the discussions. While agreeing for cooperation on modernisation and upgradation, Japan has agreed to assist the public transporter in achieving its zero-accident mission. 
image
Logical Indian
Railways research wing - Research Designs & Standards Organisation (RDSO), will sign an MoU with Railway Technical Research Institute of Japan to carry out research work on acquiring modern technology for the public transporter, as per the finalisation of the action plan. Prabhu also held meetings with heads of leading financial institutions and highlighted the investment prospects in railways in the coming years. Railways has chalked out a plan to investment $140 billion in infrastructure upgradation in the next five years, the release said. 
Japan will also provide its expertise and technology in solving problems of sanitation including the development of waterless, odourless toilets in trains and at stations, it added. Besides, the country has also agreed to assist Indian Railways in development of a legal and regulatory framework on high speed railway here, the official statement said.