Welcome, guest | Sign In | My Account | Store | Cart

This recipe shows how to use the 'speech' (or 'pyspeech' - it seems to have two names) Python library to make the computer recognize what you say and convert it to text. Note: This library did not always give correct results for me, so it may not be advisable to use it in production. Also, the pyspeech site says that the library is no longer being maintained. Use at your own risk.

Python, 11 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
import string
import speech

while True:
    print "Talk:"
    phrase = speech.input()
    speech.say("You said %s" % phrase)
    print "You said {0}".format(phrase)
    #if phrase == "turn off":
    if phrase.lower() == "goodbye":
        break

I tested it with several voice inputs (mine), and it gave mixed results. Worked right in some cases, wrong in others.

This blog post has more details and sample output:

http://jugad2.blogspot.in/2014/03/speech-recognition-with-python-speech.html