2016-08-04 39 views
1

Ich mag Sprache konvertieren und in Echtzeit in Text das Modul mit SpeechRecognition 3.4.6 ich alles installiert habe und jetzt versuche ich, einen einfachen Code aus Beispiel ist hier der Code:Erster Typeerror mit speech_recognition Modul in Python

import speech_recognition as sr 

# obtain audio from the microphone 
r = sr.Recognizer() 
with sr.Microphone() as source: 
    print("Say something!") 
    audio = r.listen(source) 

# recognize speech using Sphinx 
try: 
    print("Sphinx thinks you said " + r.recognize_sphinx(audio)) 
except sr.UnknownValueError: 
    print("Sphinx could not understand audio") 
except sr.RequestError as e: 
    print("Sphinx error; {0}".format(e)) 

ich erhalte Fehler in Zeile audio = r.listen(source), der Fehler ist Traceback:

Traceback (most recent call last): 
File "sr.py", line 4, in <module> 
audio = r.listen(source)     # listen for the first phrase and extract it into audio data 
File "/usr/local/lib/python2.7/dist- packages/speech_recognition/__init__.py", line 493, in listen 
buffer = source.stream.read(source.CHUNK) 
File "/usr/local/lib/python2.7/dist-packages/speech_recognition/__init__.py", line 139, in read 
    return self.pyaudio_stream.read(size, exception_on_overflow = False) 
    File "/usr/local/lib/python2.7/dist-packages/pyaudio.py", line 608, in read 
return pa.read_stream(self._stream, num_frames, exception_on_overflow) 
TypeError: function takes exactly 2 arguments (3 given) 

Antwort

0

Sie benötigen pyaudio 0.2.9 zu installieren, es scheint, dass Sie ältere Version haben

0

Es scheint, dass die Version von Python zu alt ist.