我正在尝试下载pyaudio,当我使用pipwin安装pyaudio时,它可以工作。 但是,当我尝试运行代码时,出现以下错误:
C:\Users\Lalo\PycharmProjects\untitled\venv\Scripts\python.exe C:/Users/Lalo/PycharmProjects/untitled/test
Traceback (most recent call last):
File "C:\Users\Lalo\PycharmProjects\untitled\venv\lib\site-packages\speech_recognition\__init__.py", line 108, in get_pyaudio
import pyaudio
ModuleNotFoundError: No module named 'pyaudio'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/Lalo/PycharmProjects/untitled/test", line 32, in <module>
recordAudio()
File "C:/Users/Lalo/PycharmProjects/untitled/test", line 16, in recordAudio
with sr.Microphone() as source:
File "C:\Users\Lalo\PycharmProjects\untitled\venv\lib\site-packages\speech_recognition\__init__.py", line 79, in __init__
self.pyaudio_module = self.get_pyaudio()
File "C:\Users\Lalo\PycharmProjects\untitled\venv\lib\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
Process finished with exit code 1
我尝试运行的代码是:
import speech_recognition as sr
import os
from gtts import gTTS
import datetime
import warnings
import calendar
import random
import wikipedia
warnings.filterwarnings('ignore')
def recordAudio():
r = sr.Recognizer()
with sr.Microphone() as source:
print("iets ")
audio = r.listen(source)
data = ''
try:
data = r.recognize_google(audio)
print('you said:'+ data)
except sr.UnknownValueError:
print("snap niet")
except sr.RequestError as e:
print('falta')
return data
recordAudio()
In this image you can see that when i try to install pyaudio again, it says that it already is there
如果有人可以帮助我,我将非常感激。 我使用的python是3.8.4 64位。
以友好的问候