From 4fed7933625e313172321dc053935063cf877253 Mon Sep 17 00:00:00 2001 From: t1m0thyj Date: Mon, 16 Oct 2017 12:55:58 -0400 Subject: [PATCH] Improved code for IP address action --- src/assistant_library_with_local_commands_demo.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/assistant_library_with_local_commands_demo.py b/src/assistant_library_with_local_commands_demo.py index 1d36806d..e0d10414 100755 --- a/src/assistant_library_with_local_commands_demo.py +++ b/src/assistant_library_with_local_commands_demo.py @@ -51,8 +51,8 @@ def reboot_pi(): def say_ip(): - ip_address = subprocess.check_output("hostname -I | cut -d' ' -f1", shell=True).decode("utf8") - aiy.audio.say("My IP address is " + ip_address) + ip_address = subprocess.check_output("hostname -I | cut -d' ' -f1", shell=True) + aiy.audio.say('My IP address is %s' % ip_address.decode('utf-8')) def process_event(assistant, event): @@ -66,15 +66,15 @@ def process_event(assistant, event): status_ui.status('listening') elif event.type == EventType.ON_RECOGNIZING_SPEECH_FINISHED and event.args: - text = event.args['text'] - print('You said:', text) + print('You said:', event.args['text']) + text = event.args['text'].lower() if text == 'raspberry power off': assistant.stop_conversation() power_off_pi() elif text == 'raspberry reboot': assistant.stop_conversation() reboot_pi() - elif text == 'IP address': + elif text == 'ip address': assistant.stop_conversation() say_ip()