Mail.ruПочтаМой МирОдноклассникиВКонтактеИгрыЗнакомстваНовостиКалендарьОблакоЗаметкиВсе проекты

Выдает ошибку непонятную в Python

Luke Art Ученик (39), открыт 3 недели назад
выводит ошибку помогите пж
код:
 import speech_recognition 

sr = speech_recognition.Recognizer()
sr.pause_threshold = 0.8


def greeting():
return 'здравствуйте сэр'


with speech_recognition.Microphone() as source:
sr.adjust_for_ambient_noise(source=source, duration=0.5)
audio = sr.listen(source=source)
query = sr.recognize_google(audio_data=audio, language='ru-RU').lower()

if query == 'джарвис привет':
print(greeting())

else:
print('критические неполадки критические неполадки')
 ошибка:

  
Traceback (most recent call last):
File "C:\Users\timek\Desktop\pythonProject11224\.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\timek\Desktop\pythonProject11224\main.py", line 11, in
with speech_recognition.Microphone() as source:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\timek\Desktop\pythonProject11224\.venv\Lib\site-packages\speech_recognition\__init__.py", line 79, in __init__
self.pyaudio_module = self.get_pyaudio()
^^^^^^^^^^^^^^^^^^
File "C:\Users\timek\Desktop\pythonProject11224\.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
2 ответа
CPT Просветленный (21570) 3 недели назад
The error message indicates that the Python module "pyaudio" is missing from your environment. This module is essential for the speech_recognition library to interact with your microphone and process audio input.
Here's how to fix it:
Install PyAudio:
Using pip: Open your terminal or command prompt and run the following command:

 pip install pyaudio 


 conda install -c conda-forge pyaudio 
Verify Installation:
After installation, try running your Python script again. The error should be resolved, and your speech recognition code should work as expected.
Алекс Куха Высший разум (446977) 3 недели назад
Как удалось установить speech_recognition и не установить pyaudio?
Похожие вопросы