这是我在我的 pi 上启动并运行的,它使用 python 语音识别、pyaudio 和 python espeak 进行语音响应(如果你想要的话,如果不只是把它拿出来)这将监听语音输入,将其打印到文本和告诉你..你可以操纵它来做任何你想做的事情——
import pyaudio
from subprocess import call
import speech_recognition
r = sr.Recognizer()
r.energy_threshold=4000
with sr.Microphone(device_index = 2, sample_rate = 44100, chunk_size = 512) as source:
print 'listening..'
audio = r.listen(source)
print 'processing'
try:
message = (r.recognize_google(audio, language = 'en-us', show_all=False))
call(["espeak", message])
except:
call(['espeak', 'Could not understand you'])