0

I have tried to make a Voice assistance using pyAudio, i have installed correct version of pyAudio for my python version but i have some module error poping up after running program, i hope someone can help me.

import os
import time
import playsound
import speech_recognition as sr
from gtts import gTTS

def speak(text):
    tts = gTTS(text=text)
    filename = "voice.mp3"
    tts.save(filename)
    playsound.playsound(filename)
    os.remove(filename)

def get_audio():
        r = sr.Recognizer()
        with sr.Microphone() as source :
            audio = r.listen(source)
            said = ""

            try:
                said = r.recognize_google(audio, language = 'en-EN')
                print(said)
            except Exception as e:
                print("It didn't worked ")
        return said


text = get_audio()

if "hello" in text:
    speak("hello how are you")

if "what is your name" in text:
    speak("My name is timmy")

Errors

Traceback (most recent call last):
  File "C:/Users/Home/PycharmProjects/JARVIS/main.py", line 28, in <module>
    text = get_audio()
  File "C:/Users/Home/PycharmProjects/JARVIS/main.py", line 16, in get_audio
    with sr.Microphone() as source :
  File "C:\Users\Home\PycharmProjects\JARVIS\venv\lib\site-packages\speech_recognition\__init__.py", line 138, in __enter__
    self.audio.open(
  File "C:\Users\Home\PycharmProjects\JARVIS\venv\lib\site-packages\pyaudio.py", line 750, in open
    stream = Stream(self, *args, **kwargs)
  File "C:\Users\Home\PycharmProjects\JARVIS\venv\lib\site-packages\pyaudio.py", line 441, in __init__
    self._stream = pa.open(**arguments)
OSError: [Errno -9999] Unanticipated host error

0 Answers0