I tried to create a virtual assistant in pyhton but when starting my code the microphone of my computer does not detect it and ends with -1

0
import pyttsx3
import speech_recognition as sr
import pocketsphinx
import pyaudio
engine =pyttsx3.init()

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

def mainfunction():
    a = r.listen(source)
    user = r.recognize_sphinx(a)
    print (user)

speak('hello')

if __name__=="__main__":
    r= sr.Recognizer()
    with sr.Microphone() as source:
        while 1:
            mainfunction()
    
asked by Marcos Zapata 08.08.2018 в 04:55
source

0 answers