2017-12-31 236 views
1

pyAudio가 설치된 Python 2.7에서 다음 코드를 실행하고 있습니다. 나는 this 자습서를 사용합니다.음성 인식 파이썬이 수신 대기 중입니다.

import speech_recognition as sr 

r = sr.Recognizer() 
with sr.Microphone() as source: 
    print("Speak:") 
    audio = r.listen(source) 

try: 
    print("You said " + r.recognize_google(audio)) 
except sr.UnknownValueError: 
    print("Could not understand audio") 
except sr.RequestError as e: 
    print("Could not request results; {0}".format(e)) 

파이썬은 "오디오 = r.listen (소스)"

+0

:) 도움을 바랍니다! 그들이 python3를 사용는/usr/빈/ENV의 python3' 있도록. 어쩌면 당신은 python2.7을위한 모순 된 모듈을 가지고있을 것입니다. 오류가 발생 했습니까? 반환 된'r.listen (source)'오디오 인스턴스? – bierschi

+0

'python -m speech_recognition'을 실행하고 그것이 작동하고 단어를 인식하는지 확인하십시오. –

답변

1

나는 100 % 확실하지 오전하지만 난 잠시 다시이 문제가 있다고 생각과는 함께 할 수있는 뭔가가 될 수 행에 정지 마이크 소스. MICROPHONE_INDEX가 하드웨어 관련 마이크의 인덱스

이 MICROPHONE_INDEX 어떤 값을 알아낼가 어디 있는지 ...에 의해 마이크에 마이크() (device_index = MICROPHONE_INDEX)의

변화 모든 인스턴스를 고칠 수 시험을 지금

Microphone with name "HDA Intel HDMI: 0 (hw:0,3)" found for `Microphone(device_index=0)` 
Microphone with name "HDA Intel HDMI: 1 (hw:0,7)" found for `Microphone(device_index=1)` 
Microphone with name "HDA Intel HDMI: 2 (hw:0,8)" found for `Microphone(device_index=2)` 
Microphone with name "Blue Snowball: USB Audio (hw:1,0)" found for `Microphone(device_index=3)` 
Microphone with name "hdmi" found for `Microphone(device_index=4)` 
Microphone with name "pulse" found for `Microphone(device_index=5)` 
Microphone with name "default" found for `Microphone(device_index=6)` 

: 이것은 다음과 같이 뭔가를 인쇄합니다

import speech_recognition as sr 
for index, name in enumerate(sr.Microphone.list_microphone_names()): 
    print("Microphone with name \"{1}\" found for `Microphone(device_index={0})`".format(index, name)) 

: 수, 다음 코드를 실행해야합니다 예를 들어 Snowball 마이크를 사용하려면 마이크()를 마이크 (device_index = 3)로 변경합니다.

나는이 그들이 오두막 '#을 사용하는 튜토리얼에서