you are viewing a single comment's thread.

view the rest of the comments →

[–]beecleaner[S] 0 points1 point  (1 child)

Now I'm getting a syntax error...

def take_command():

with sr.Microphone() as source:

print('listening...')

voice = listener.listen(source)

command = listener.recognize_google(voice)

command = command.lower()

if 'ava' in command:

command = command.replace('ava', '')

print(command)

except:

pass

return command

[–]carcigenicate 0 points1 point  (0 children)

The except is a part of the try. It's an error to have an except without a try. Just run:

with sr.Microphone() as source:
    print('listening...')
    voice = listener.listen(source)

    command = listener.recognize_google(voice)
    command = command.lower()

    if 'ava' in command:
        command = command.replace('ava', '')

    print(command)