Monday, 25 May 2015

Create a voice recognizer application in python.

Requirements:
# python 2.7

pip install SpeechRecognition

## uncompress PyAduio for PortAudio

pip install jack

#command: jack_control start, status, stop
# ulimit -a # for check sys config

sudo apt-get install jackd2


FLAC

application code sample:
# Recognize speech from micro phoneimport pyaudio #package manually installedimport speech_recognition as sr

p = pyaudio.PyAudio()
index = int(p.get_device_count() - 1)


r = sr.Recognizer()
#source: source of voice#timeour: microphone channel for up to two seconds waiting for a signalwith sr.Microphone() as source:
    aud = r.listen(source=source, timeout=5) #source means source of voice: michrophone or wavefile, timeout: michrophone    r.energy_threshold = 2000    r.pause_threshold = .5
try:
    print("you said:" + r.recognize(aud))
except LookupError:
    print("could rr not recognize")

No comments:

Post a Comment