-1

I am trying to create a Voice Assistant but cannot get over this error from this code as nothing is helping me out even looking it up.

import datetime
import pywhatkit
import wikipedia

listener = sr.Recognizer()
alexa = pyttsx3.init()
voices = alexa.getProperty('voices')
Michael M.
  • 10,486
  • 9
  • 18
  • 34
Michael
  • 1
  • 2
  • II am getting a KeyError:Value for these codes right here and have no idea what configuration I got them wrong. listener = sr.Recognizer() alexa = pyttsx3.init() voices = alexa.getProperty('voices') – Michael Jan 15 '23 at 08:05

1 Answers1

0
try:
   with sr.Microphone() as source:
      print('Device is listening, please speak...')
      voice = listener.listen(source)
      command = listener.recognize_google(voice)
      command = command.lower()
      if 'alexa' in command:
          print(command)

except: pass

Michael
  • 1
  • 2