python – 如何获得PyAudio 0.2.11版本

python – 如何获得PyAudio 0.2.11版本,第1张

概述当我运行bingtest.py时,我收到以下错误. 我尝试过使用该命令 sudo pip install PyAudio 但它似乎没有用. Traceback (most recent call last): File "bingtest.py", line 8, in <module> m = sr.Microphone() File "/usr/local/lib/p 当我运行bingtest.py时,我收到以下错误.

我尝试过使用该命令

sudo pip install PyAudio

但它似乎没有用.

Traceback (most recent call last):    file "bingtest.py",line 8,in <module>     m = sr.Microphone()    file "/usr/local/lib/python2.7/dist-  packages/speech_recognition/__init__.py",line 79,in __init__      self.pyaudio_module = self.get_pyaudio()    file "/usr/local/lib/python2.7/dist-  packages/speech_recognition/__init__.py",line 113,in get_pyaudio  raise AttributeError("PyAudio 0.2.11 or later is required (found    version {})".format(pyaudio.__version__))  AttributeError: PyAudio 0.2.11 or later is required (found version 0.2.8)

bingtest.py

#!/usr/bin/env python3# NOTE: this example requires PyAudio because it uses the Microphone classimport osimport speech_recognition as srimport timer = sr.Recognizer()m = sr.Microphone()def callback(recognizer,audio):BING_KEY = "xxxxxx" # Microsoft Bing Voice Recognitiontry:    var=r.recognize_bing(audio,key=BING_KEY)    print("audio Listened...")    print("Microsoft Bing Voice Recognition thinks you saID " + var)    if(var=="open Chrome"):        os.system("Google-Chrome")except sr.UnkNownValueError:    print("Microsoft Bing Voice Recognition Could not understand audio")except sr.RequestError as e:    print("Could not request results from Microsoft Bing Voice Recognition service; {0}".format(e))returndef call_bing():# obtain audio from the microphone  with m as source:    print ("say something:")    r.adjust_for_ambIEnt_noise(source)  stop_Listening = r.Listen_in_background(m,callback)  for _ in range(60): time.sleep(0.1)  stop_Listening()call_bing()print "returned to main from bing function"call_bing()call_bing()
解决方法 试试这个.首先你必须安装PyAudio,然后使用pip升级它

sudo pip install PyAudiopip install --upgrade PyAudio
总结

以上是内存溢出为你收集整理的python – 如何获得PyAudio 0.2.11版本全部内容,希望文章能够帮你解决python – 如何获得PyAudio 0.2.11版本所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1196359.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-03
下一篇 2022-06-03

发表评论

登录后才能评论

评论列表(0条)

保存