【问题标题】:Facing trouble in installing PyAudio在安装 PyAudio 时遇到问题
【发布时间】:2020-03-10 11:51:11
【问题描述】:

我正在尝试让 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

安装错误

文件“c:\users\user\appdata\local\programs\python\python38-32\lib\zipfile.py”,第 1336 行,在 _RealGetContents raise BadZipFile("文件不是 zip 文件") zipfile.BadZipFile: 文件不是 zip 文件

【问题讨论】:

  • 您是否尝试从 Gohlke 下载轮子并通过 pip 安装它?
  • 这是 XY 问题的示例 - 显然您在安装 PyAudio 时遇到了麻烦。这又会导致您引用的 AttributeError 。提出正确的问题。
  • 不!我是第一次使用,请告诉我如何使用它
  • 从这里为您的系统下载 PyAudio lfd.uci.edu/~gohlke/pythonlibs/#pyaudio 这就是 pipwin 正在为您做的事情。然后运行pip install path_to_wheel\pyaudio_wheel.whl。当然用实际路径和文件名替换path_to_wheel\pyaudio_wheel.whl

标签: python python-3.x pyaudio


【解决方案1】:

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

然后在您的下载文件夹中打开一个 powershell 窗口并输入:-

pip install PyAu

然后按tab,它会自动完成并按enter。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-11
    • 2013-12-24
    • 2020-02-27
    • 2018-02-25
    • 2011-06-06
    • 2021-04-14
    相关资源
    最近更新 更多