Building a Speech Recognition with Python on Raspberry Pi

Recently I spent some money (less than $100) and time to build a speech recognition script with Python which can be run on my Raspberry Pi 2. Since I bought a RPi 2 as my media player, I was thinking to put my old RPi B+ to do something fun. So I started the speech recognition project.

Unfortunately, RPi B+ seems to be just too slow to handle the task. So I ended up buying another RPi 2. The script basically does three things:

1) Convert audio input to text
2) Respond to the text from step 1 and come up with response in text
3) Convert the response text into audio output.

So here are a couple demos I made in the last few days. You might need to turn up the volume to hear what I said in the videos. Let me know what you think.

Demo 1: At this point, the script can only answer the date and the time.

Demo 2: The script can access Internet to find answers to the questions.

Share this Story

About chaoming.li

Technology entrepreneur, web analytics specialist, Internet enthusiasts. I also like movies, computer games, history and other interesting stuff. I was born in Guangzhou China and I live in Sydney Australia now.


  1. Awesome! Awesome, This is the most amazing stuff done with a Raspberry Pi . Please share your source code I am working on something similar Please share your source code . Share your knowledge with the world. I have search online and THIS IS THE BEST PROJECT DONE WITH A RASPBERRY PI. WOW. Please share your code for recognition.

  2. Dear Li,

    Do you mind share your source code for this project “building-a-speech-recognition-with-python-on-raspberry-pi” to me?

    My email is fb12043@gmail.com

    Thanks you and have a nice day.

  3. Hey man! What scripts are you using on python? Where do I get them? How do I set up? Please help :)

  4. Thank you for your comments above, guys.

    I am quite busy with my 4 month’s old daughter so I haven’t done anything in the last few months. And my RPi crashed so I don’t have the Python source code now.

    The Python script is rather simple. It uses the Python speech recognition from Anthony Zhang (https://github.com/Uberi/speech_recognition) to process the input. Any Text to Voice library will handle the output. My script looked at the input text to see if it is a question for definition of something. If yes, it goes to Wikipedia to retrieve the first paragraph. If not, it goes to an search engine API to post the question to see if it can get an answer.

    If anyone has experience with RPi crashing, please let me know. My RPi 2 can work for a few days (used for VPN and BT) and then it crashes and it wouldn’t start properly. My RPi B+ can’t even boot up at all. I am not sure what’s going on. It seems RPi is not a stable hardware for running Linux.

    • Hi, can you tell me how to change the recognition language? to russian , for example.

      • I used Google Speech API which can support Russian, I believe. The language is just a parameter you pass with the sound file.

        • The recognizer doesn’t understand my particular language/dialect.

          Try setting the recognition language to your language/dialect. To do this, see the documentation for recognizer_instance.recognize_google, recognizer_instance.recognize_wit, recognizer_instance.recognize_ibm, and recognizer_instance.recognize_att.

          For example, if your language/dialect is British English, it is better to use “en-GB” as the language rather than “en-US”.

          I changed all these settings to “ru” , but it still understands english

Leave a Reply

Your email address will not be published. Required fields are marked *


© Copyright 2014, All Rights Reserved