2014-11-20 2 views
0

파이썬 Speech Recognition library을 사용하여 마이크의 음성 입력을 인식하고 있습니다.Pyaudio : no get_device_count 메서드

내 기본 마이크에서 정상적으로 작동합니다. 이것은 내가 사용하고있는 코드입니다. 1. 나는이 오류를 받고 있어요 - 나는 문서

Creates a new Microphone instance, which represents a physical microphone on the computer. Subclass of AudioSource.

If device_index is unspecified or None, the default microphone is used as the audio source. Otherwise, device_index should be the index of the device to use for audio input. https://pypi.python.org/pypi/SpeechRecognition/

의 이해 무엇에 따르면 문제는 내가 pyaudio.get_device_count와 노드를 취득하고자 할 때()이다.

AttributeError : '모듈'개체가 어떤 속성 'get_device_count'

그래서 내가 버그로 된 USB 마이크

import pyaudio 
import speech_recognition as sr 

index = pyaudio.get_device_count() - 1 
print index 

r = sr.Recognizer() 

with sr.Microphone(index) as source: 
    audio = r.listen(source) 

try: 
    print("You said " + r.recognize(audio)) 
except LookupError:       
    print("Could not understand audio") 
+0

pyaudio 버전을 사용하고 있다는 것을 언급 할만한 가치가 있습니다. –

답변

0
myPyAudio=pyaudio.PyAudio() 
print "Seeing pyaudio devices:",myPyAudio.get_device_count() 
+0

동일한 문제를 해결하기 위해 노력하고 있습니다. 내 공격 라인은 Microphone 클래스를 만드는 곳에서 __init__.py를 찾는 것입니다. 이 함수를 수정합니다 : 클래스 마이크를 초기화하는 입력이 None이면 마이크가있는 카드에 해당하는 AudioSource를 만들고 마이크를 초기화하려면 해당 소스를 사용합니다. –

+0

제 경우에는 제 나무 딸기 파이에 기본 사운드 카드에 입력 기능이 없으므로 크릭을 사용하고 있습니다. 그래서 Logitech C310 인 USB 사운드 "카드"와 마이크를 연결해야합니다. –

+0

BBB와 함께 작동하려고합니다. 만약 당신이 그것을 할 수있는 일을 알려주십시오 – Diego

0

를 사용하기 위해 마이크를 구성하는 방법을 잘 모르겠어요이 없습니다 도서관. 방금 1.3.1에서 수정 사항을 푸시 했으므로 이제 수정해야합니다!

버전 1.3.1은 이전 버전과 완전히 하위 호환성을 유지합니다.