我的问题是很简单,我如何这样做。
def user_commands():
def take_command():
try:
with sr.Microphone() as source:
print( listening... )
voice = listener.listen(source)
command = listener.recognize_google(voice)
command = command.lower()
if alexa in command:
command = command.replace( alexa , )
print(command)
except:
pass
return command
def run_alexa():
global command
command = user_commands()
what is happening when I do this is:
NameError: name command is not defined