在安装PyAudio时遇到麻烦

时间:2020-03-10 11:51:11

标签: python python-3.x pyaudio

我正在尝试使Jarvis像程序一样但出现错误

AttributeError:找不到PyAudio;检查安装

import speech_recognition
import pyttsx3

speech_engine = pyttsx3.init('sapi5')
speech_engine.setProperty('rate', 150)

def speak(text):
    speech_engine.say(text)
    speech_engine.runAndWait()

recognizer = speech_recognition.Recognizer()

def listen():
    with speech_recognition.Microphone() as source:
        recognizer.adjust_for_ambient_noise(source)
        audio = recognizer.listen(source)

    try:
        return recognizer.recognize_sphinx(audio)
        # or: return recognizer.recognize_google(audio)
    except speech_recognition.UnknownValueError:
        print("Could not understand audio")
    except speech_recognition.RequestError as e:
        print("Recog Error; {0}".format(e))

    return ""

speak("Say something!")
speak("I heard you say " + listen())

我尝试安装pyaudio,但安装错误

pip install pipwin

pipwin install pyaudio

安装错误

_RealGetContents中的文件“ c:\ users \ user \ appdata \ local \ programs \ python \ python38-32 \ lib \ zipfile.py”,行1336 引发BadZipFile(“文件不是zip文件”) zipfile.BadZipFile:文件不是zip文件

1 个答案:

答案 0 :(得分:0)

转到this链接并找到PyAudio,然后为您的python版本下载一个。

然后在您的下载文件夹中打开一个Powershell窗口,然后键入:-

pip install PyAu

,然后按 tab ,它将自动完成并按输入