【发布时间】:2017-11-05 12:09:45
【问题描述】:
我已经使用 brew 安装了 portaudio,并在我的 macos 中使用 pip3 安装了 SpeechRecognition 和 pyaudio。 运行以下代码时出现错误
代码:
#!/usr/bin/env python
# Python 3
import os
import sys
import speech_recognition as sr
r = sr.Recognizer()
with sr.Microphone() as source:
print ("say something!");
audio = r.listen(source)
try:
print("google thinks you said" +r.recognize_google(audio))
except:
pass
错误:
Traceback (most recent call last):
File "test.py", line 8, in <module>
with sr.Microphone() as source:
File "/Library/Python/2.7/site-
packages/speech_recognition/__init__.py", line 79, in __init__
self.pyaudio_module = self.get_pyaudio()
File "/Library/Python/2.7/site-
packages/speech_recognition/__init__.py", line 110, in get_pyaudio
raise AttributeError("Could not find PyAudio; check
installation")
AttributeError: Could not find PyAudio; check installation
我正在使用 python-shell 在我的 nodejs 应用程序中运行这个 python 脚本。 当我只用 python3 test.py 运行这个脚本时,它可以工作,但是用 python test.py,它不能工作。 在我的节点应用程序中它也不起作用。我认为节点在基本的python 2.7 版上执行这个脚本。 我正在使用 MacOs sierra 操作系统。
请帮助我提前谢谢:-)
【问题讨论】:
标签: python python-3.x speech-recognition pyaudio