Exemplo n.º 1
0
def send_cmds_to_ev3(ev3):
    """
    This function reads the global command queue cmd_q and sends each of the command to the EV3 with
    an appropriate delay between them.  The param ev3 is the pointer to the EV3.
    This is meant to be run as a thread
    """
    inter_cmd_wait = 2  # Sec.  Min delay between successive commands

    print('ENTERED send_cmds_to_ev3 function/thread, cmd_q length is {}',
          format(cmd_q.qsize()))

    while True:

        try:
            cmd = cmd_q.get(
            )  # This should block the thread if the queue is empty
            print("-> Command from file is {}".format(cmd))
            m = ev3_rpi_ctrl_pkg.messageGuin(
                "EV3-CMD", cmd,
                "text")  #  convert message; select EV3-CMD block to send to
            print('Sending to EV3 msg: {}'.format(cmd))
            ev3_rpi_ctrl_pkg.messageSend(ev3, m)  # send converted message

            if cmd == "STOPEV3":
                ev3.close()
                return  #Thread terminates
            else:
                time.sleep(
                    inter_cmd_wait
                )  # wait some time until the next commad can be sent

        except KeyboardInterrupt:
            break
Exemplo n.º 2
0
def send_cmds_to_ev3(ev3):
    """
    This function reads the global command queue cmd_q and sends each of the command to the EV3 with
    an appropriate delay between them.  The param ev3 is the pointer to the EV3.
    This is meant to be run as a thread
    """
    global thread_stop
    inter_cmd_wait = 2  # Sec.  Min delay between successive commands

    print('ENTERED send_cmds_to_ev3 function/thread, cmd_q length is {}',
          format(cmd_q.qsize()))

    while not thread_stop:

        try:
            cmd = cmd_q.get(
                block=True, timeout=inter_cmd_wait
            )  # This should block the thread if the queue is empty
            print("-> Command from file is {}".format(cmd))

            if len(cmd) == 0 or cmd.isspace(
            ):  # Skip commands that are blank or only whitespace
                continue

            if cmd == "EXIT":
                thread_stop = True  # Stop all threads and allow the program to exit
                print(
                    "-> FROM send_cmds_to_ev3, processing EXIT, thread_stop = {}"
                    .format(thread_stop))
                break  # Close the open file and end the thread

            m = ev3_rpi_ctrl_pkg.messageGuin(
                "EV3-CMD", cmd,
                "text")  #  convert message; select EV3-CMD block to send to
            #             print('Sending to EV3 msg: {}'.format(cmd))
            ev3_rpi_ctrl_pkg.messageSend(ev3, m)  # send converted message

            #             if cmd=="STOPEV3":
            #                 break                               # thread terminates gracefully
            ##                ev3.close()
            ##                return                                 #Thread terminates
            #             else:
            #                 time.sleep(inter_cmd_wait)           # wait some time until the next commad can be sent
            # The command STOPEV3 should not terminate the thread

            time.sleep(inter_cmd_wait
                       )  # wait some time until the next commad can be sent

        except KeyboardInterrupt:
            break

        except Queue.Empty as e:
            #             print('FROM send_cmds_to_ev3, EXCEPTION IS {}'.format(e))
            continue

    ev3.close()

    print('EXITED send_cmds_to_ev3')
    return
Exemplo n.º 3
0
def poll_cmd_file(ev3, ev3_cmd_filename, wait_period):
    """
    This function repeated checks the command file ev3_cmd_filename that is created by the AIY Voice program and checks if it has anything
    in it.  If it does, it send the commnand to the ev3 over the bluetooth interface.  It ends when it is  interupted by the user
    """
    print('ENTERED poll_cmd_file with name = {} wait_period = {}'.format(
        ev3_cmd_filename, wait_period))

    while True:

        do_sleep = False

        try:
            ev3_file = open(ev3_cmd_filename, "r")
        except IOError:
            do_sleep = True  # and try again
        except KeyboardInterrupt:
            break

        if do_sleep:
            try:
                time.sleep(wait_period)  # Wait for the file to be created
                continue
            except KeyboardInterrupt:
                break

        cmds = ev3_file.read().splitlines(
        )  # get all commands and remove the line terminatorsd  (\n)

        try:

            for cmd in cmds:
                print("-> Command from file is {}".format(cmd))
                if cmd is not None:
                    m = ev3_rpi_ctrl_pkg.messageGuin(
                        "EV3-CMD", cmd, "text"
                    )  #  convert message; select EV3-CMD block to send to
                    print('Sending to EV3 msg: {}'.format(cmd))
                    ev3_rpi_ctrl_pkg.messageSend(ev3,
                                                 m)  # send converted message
                    if cmd == "STOPEV3":
                        return  #Thread terminates

                    time.sleep(3)  # DELETE--FOR DEBUGGING ONLY

        except KeyboardInterrupt:
            break

        if ev3_file is not None:
            os.remove(
                ev3_cmd_filename
            )  # Delete processed commands so that voice_assist_ev3_ctrl can make more

    ev3.close()
Exemplo n.º 4
0
def main():

    ev3_cmd_filename = '/home/pi/Lego_ev3/ev3_cmds.txt'  # Command destined for the EV3 should be written here by voice_assist_ev3_ctrlx.py
    wait_period = 0.25  # SEC.  This is the amount of time to wait for the voice_assist_ev3_ctrlx to creat a file

    ev3, ev3PortOpen = ev3_rpi_ctrl_pkg.openEv3(
    )  #Port poitner abd ID if successful, None otherwise

    if ev3PortOpen is not None:
        print('\nOpened EV3 Brick on {}'.format(ev3PortOpen))
        # Get the pointer to the open BT interface
    else:  # If no port are found

        print('EV3 does not appear to be open on any /dev/rfcomm port')
        sys.exit()

    while True:

        try:
            ev3_file = open(ev3_cmd_filename, "r")
        except IOError:
            time.sleep(wait_period)  # Wait for the file to be created
            continue  # and try again
        except KeyboardInterrupt:
            break

        cmds = ev3_file.read().splitlines(
        )  # get all commands and remove the line terminatorsd  (\n)

        try:

            for cmd in cmds:
                print("-> Command from file is {}".format(cmd))
                if cmd is not None:
                    m = ev3_rpi_ctrl_pkg.messageGuin(
                        "EV3-CMD", cmd, "text"
                    )  #  convert message; select EV3-CMD block to send to
                    print('Sending to EV3 msg: {}'.format(cmd))
                    ev3_rpi_ctrl_pkg.messageSend(ev3,
                                                 m)  # send converted message
                    time.sleep(3)  # DELETE--FOR DEBUGGING ONLY

        except KeyboardInterrupt:
            break

        if ev3_file is not None:
            os.remove(
                ev3_cmd_filename
            )  # Delete processed commands so that voice_assist_ev3_ctrl can make more

    ev3.close()
    sys.exit()
Exemplo n.º 5
0
def process_event(assistant, event):
    # Function returns a Boolean.  True means user asked the conversation to end; false otherwise

    global EV3  # THis is the pointer to the LEGO EV3

    print('*** PROCESS EVENT: Point 0--Begin Process Event')
    status_ui = aiy.voicehat.get_status_ui()
    if event.type == EventType.ON_START_FINISHED:
        print('*** PROCESS EVENT: Point 1--ON_START_FINISHED')
        status_ui.status('ready')
        if sys.stdout.isatty():
            print('Say "OK, Google" then speak, or press Ctrl+C to quit...')

    elif event.type == EventType.ON_CONVERSATION_TURN_STARTED:
        print('*** PROCESS EVENT: Point 2--ON CONVERSATION TURN STARTED')
        status_ui.status('listening')

    elif event.type == EventType.ON_RECOGNIZING_SPEECH_FINISHED and event.args:
        print('You said:', event.args['text'])
        print('*** PROCESS EVENT: Point 3--ON RECOGNIZING_SPEECH_FINISHED')
        text = event.args['text'].lower()
        if text == 'power off':
            print('*** PROCESS EVENT: Point 4--Local Power Off')
            assistant.stop_conversation()
            power_off_pi()
        elif text == 'reboot':
            print('*** PROCESS EVENT: Point 5--Local Reboot')
            assistant.stop_conversation()
            reboot_pi()
        elif text == 'ip address':
            print('*** PROCESS EVENT: Point 6--Local IP Address')
            assistant.stop_conversation()
            say_ip()
        elif text == 'ev3 forward' or text == 'lego forward':
            print('*** PROCESS EVENT: Point 7--Local EV3 Forward')
            assistant.stop_conversation()
            ev3Msg = "FWD"
            print('*** ENTERING messageGuin')
            ##            m = ev3_rpi_ctrl_pkg.messageGuin("EV3-CMD", 10.1,"number")  # SPG: DELETE THIS cFOR TEST ONLY
            m = ev3_rpi_ctrl_pkg.messageGuin(
                "EV3-CMD", ev3Msg, "text"
            )  # SPG: UNCOMMENT THIS convert message; select EV3-CMD block to send to
            ##            print('*** EV3 is {}; EV3.isOpen() is {}'.format(EV3))
            ##            print('*** EV3.isOpen() is {}'.format(EV3.isOpen()))
            print('*** After messageGuin()')
            print('-> EV3 Settings', EV3.get_settings())
            ##            ev3_rpi_ctrl_pkg.messageSendX(EV3)   # DELETE FOR DEBUGGING
            ##            print('*** Enter messageSendY')
            ##            ev3_rpi_ctrl_pkg.messageSendY(m)     # DELETE FOR DEBUGGING
            ##            ev3_rpi_ctrl_pkg.messageSend(EV3, m) # send converted message # DUPLICXATE OF BELOW
            if EV3 is not None and EV3.isOpen() is True:
                print('\n -> Sending to EV3 msg: {} \n'.format(ev3Msg))
                print('\n -> Encoded message to EV3: {} \n'.format(m))
                print('*** Message is of type {}'.format(type(m)))
                ##                print('*** Is instance of unicode {}'.format(isinstance(m, unicode)))
                print('*** ENTERING messageSend')
                ev3_rpi_ctrl_pkg.messageSend(EV3, m)  # send converted message


##                time.sleep(5)                         # Wait 5 sec; MAY BE NOT NEEDED
            else:
                print("\n  Can't send--EV3 is not open \n")

        elif text == 'ev3 open' or text == 'open ev3' or text == 'open lego' or text == 'lego open':
            print('*** PROCESS EVENT: Point 8--Local EV3 Open')
            assistant.stop_conversation()
            EV3, ev3Port = open_connected_ev3()  # Try to open the EV3
            ##            print('**** Returned from open_connected_ev3()')
            if EV3 is not None:
                aiy.audio.say('EV3 has been opened')
                ##                print('**** EV3 type',type(EV3))
                ##                print('**** EV3 name',EV3.name)
                print('-> EV3 Settings', EV3.get_settings())
            else:
                aiy.audio.say('EV3 has not been opened')
        elif text == 'exit':
            print('*** PROCESS EVENT: Point 9--LocaL eXIT')
            assistant.stop_conversation()
            exit_pi()
            return True  # Indicate that user asked that the conversation end

    elif event.type == EventType.ON_END_OF_UTTERANCE:
        print('*** PROCESS EVENT: Point 10--ON_END_OF_UTTERANCE')
        status_ui.status('thinking')

    elif (event.type == EventType.ON_CONVERSATION_TURN_FINISHED
          or event.type == EventType.ON_CONVERSATION_TURN_TIMEOUT
          or event.type == EventType.ON_NO_RESPONSE):
        print('*** PROCESS EVENT: Point 11')
        status_ui.status('ready')

    elif event.type == EventType.ON_ASSISTANT_ERROR and event.args and event.args[
            'is_fatal']:
        print('*** PROCESS EVENT: Point 12--FATAL')
        sys.exit(1)

    print('*** PROCESS EVENT: Point 13--EXIT PROCESS EVENT')
    return False  # User DID NOT ask for conversation to end
Exemplo n.º 6
0
def main():
##    EV3 = serial.Serial('/dev/rfcomm5',timeout=1)   
##    printSerIntInfo(EV3)
    
    global secSinceLastRx, RxToPeriod
    
##    global EV3

    timeStart = datetime.datetime.now()
    EV3, ev3PortOpen = ev3_rpi_ctrl_pkg.openEv3()               #Port poitner abd ID if successful, None otherwise
##    ev3PortOpen = ev3Info[0]
    
    print('# Ev3PortOpen {}'.format(ev3PortOpen))

##    ev3PortOpen, EV3 = ev3_rpi_ctrl_pkg.openEv3()               #Port ID if successful, False otherwise
##    ev3PortOpen = ev3Info[0]

    if ev3PortOpen is not None:
        print('\nOpened EV3 Brick on {}'.format(ev3PortOpen))
                 # Get the pointer to the open BT interface
    else:       # If no port are found
        
        print('EV3 does not appear to be open on any /dev/rfcomm port')
        sys.exit()
 

    #Debugging
##    print('End device name = ',EV3.name)
##    print('Baud rate = ', EV3.baudrate)

    timeLastRx = datetime.datetime.now()
    print("Local Time Now {}\n".format(timeLastRx))

    RxToPeriod = 5      #Seconds.  This is the amount of time that can pass before doing a buffer reset
    maxRxWait = 4       #Max time in sec to wait for message from EV3
    
    try:
    
        while True:
            userCmd = input('Command? ')                     # REALLY NOT SURE WHAT THE PROBLEM HERE IS
            userCmdUpper = userCmd.upper().strip()               #Convert to upper ans strip all spaces
            
##            userCmdUpper = getUserInput()
##            print('** COMMAND IS {}'.format(userCmdUpper))
            
            
            if "FORWARD" == userCmdUpper or "FWD" == userCmdUpper:
                ev3Msg = "FWD"
            elif "BACK" == userCmdUpper or "BACKWARDS" == userCmdUpper or "RVS" == userCmdUpper or "REVERSE" == userCmdUpper:
                ev3Msg = "RVS"
            elif "STOP" == userCmdUpper:
                ev3Msg = "STOP"
            elif "JOSHISCOOL" == userCmdUpper:
                ev3Msg = "JOSHISCOOL"
            elif "STOPEV3" == userCmdUpper or "STOPPROGRAM" == userCmdUpper:
                ev3Msg = "STOPEV3"
            elif "EXIT" == userCmdUpper or "END" == userCmdUpper:
                break
            else:
                ev3Msg = None
                
            if ev3Msg is not None:
##                err = ev3_rpi_ctrl_pkg.msg_fmt_send(EV3, "EV3-CMD",ev3Msg,"text")
##                if err:
##                    print('*** Error sending {}, err no {}'.format(ev3Msg, err))                             
                                                    
                m = ev3_rpi_ctrl_pkg.messageGuin("EV3-CMD",ev3Msg,"text")  #  convert message; select EV3-CMD block to send to
                print('Sending to EV3 msg: {}'.format(ev3Msg))
                ev3_rpi_ctrl_pkg.messageSend(EV3, m) # send converted message
            else:
                print('** Error with {}'.format(userCmd))
                
            time.sleep(2)                                # Just slow the loop a little
                
    except KeyboardInterrupt:
        # Send a stop message and stop the robot
        ev3Msg = "STOP"
        m = ev3_rpi_ctrl_pkg.messageGuin("EV3-CMD",ev3Msg,"text")  #  convert message; select EV3-CMD block to send to
        print('Sending to EV3 msg {}'.format(ev3Msg))
        ev3_rpi_ctrl_pkg.messageSend(EV3, m) # send converted message

    
    EV3.close()
    sys.exit()
Exemplo n.º 7
0
def send_cmds_to_ev3(ev3, ex_event):
    """
    This function reads the global command queue cmd_q and sends each of the command to the EV3 with
    an appropriate delay between them.  The param ev3 is the pointer to the EV3.
    This is meant to be run as a thread.  The ex_event parameter is an event() object in the threading package
    that allows this thread to shut down the other threads when it processes the EXIT command.  The var 'cmd' is now sent/specified as
    'msg_type' should be 'text', 'number' or 'logic'.  It controls the type of encoding that get sent to the EV3.
    """
    #     global thread_stop
    inter_cmd_wait = 2  # Sec.  Min delay between successive commands

    print('ENTERED send_cmds_to_ev3 function/thread, cmd_q length is {}',
          format(cmd_q.qsize()))

    while not ex_event.is_set():

        try:
            cmd = cmd_q.get(
                block=True, timeout=inter_cmd_wait
            )  # This should block the thread if the queue is empty
            print("-> Command from file is {}".format(cmd))

            if len(cmd) == 0 or cmd.isspace(
            ):  # Skip commands that are blank or only whitespace
                continue

            if cmd == "EXIT":
                #                 thread_stop = True                 # Stop all threads and allow the program to exit
                ex_event.set(
                )  #Sets the ex_event to signal other threads to shut themselves down
                print(
                    "-> FROM send_cmds_to_ev3, processing EXIT, thread_stop = {}"
                    .format(ex_event.is_set()))
                break  # Close the open file and end the thread

# Figure out if the command/parameter is all 'numeric' or not.  If it is, send as numberic; otherwise, send as 'text'
            try:
                cmd_num = float(cmd)
                cmd = cmd_num
                msg_type = 'number'
            except ValueError:
                msg_type = 'text'


#             m = ev3_rpi_ctrl_pkg.messageGuin("EV3-CMD",cmd,msg_type)  #  convert message; select EV3-CMD block to send to

            if msg_type == 'number':
                m = ev3_rpi_ctrl_pkg.encodeMessage(
                    ev3_rpi_ctrl_pkg.MessageType.Numeric, 'EV3-PARAM', cmd)
            elif msg_type == 'text':
                m = ev3_rpi_ctrl_pkg.encodeMessage(
                    ev3_rpi_ctrl_pkg.MessageType.Text, 'EV3-CMD', cmd)

            print('** Sending to EV3 msg: {}  msg_type: {}  type: {}'.format(
                cmd, msg_type, type(cmd)))
            ev3_rpi_ctrl_pkg.messageSend(ev3, m)  # send converted message

            #             if cmd=="STOPEV3":
            #                 break                               # thread terminates gracefully
            ##                ev3.close()
            ##                return                                 #Thread terminates
            #             else:
            #                 time.sleep(inter_cmd_wait)           # wait some time until the next commad can be sent
            # The command STOPEV3 should not terminate the thread

            time.sleep(inter_cmd_wait
                       )  # wait some time until the next commad can be sent

        except KeyboardInterrupt:
            break

        except Queue.Empty as e:
            #             print('FROM send_cmds_to_ev3, EXCEPTION IS {}'.format(e))
            continue

    ev3.close()

    print('EXITED send_cmds_to_ev3')
    return
Exemplo n.º 8
0
def process_event(assistant, event):
    status_ui = aiy.voicehat.get_status_ui()
    if event.type == EventType.ON_START_FINISHED:
        status_ui.status('ready')
        if sys.stdout.isatty():
            print('Say "OK, Google" then speak, or press Ctrl+C to quit...')

    elif event.type == EventType.ON_CONVERSATION_TURN_STARTED:
        status_ui.status('listening')

    elif event.type == EventType.ON_RECOGNIZING_SPEECH_FINISHED and event.args:
        print('You said:', event.args['text'])
        text = event.args['text'].lower()
        if text == 'power off':
            assistant.stop_conversation()
            power_off_pi()
        elif text == 'reboot':
            assistant.stop_conversation()
            reboot_pi()
        elif text == 'ip address':
            assistant.stop_conversation()
            say_ip()
        elif text == 'ev3 forward' or text == 'lego forward':
            ev3Msg = "FWD"
            print('*** ENTERING messageGuin')
            m = ev3_rpi_ctrl_pkg.messageGuin(
                "EV3-CMD", ev3Msg,
                "text")  #  convert message; select EV3-CMD block to send to
            ##            print('*** EV3 is {}; EV3.isOpen() is {}'.format(EV3))
            ##            print('*** EV3.isOpen() is {}'.format(EV3.isOpen()))
            print('*** After messageGuin() \n *** Enter messageSendX')
            print('-> EV3 Settings', EV3.get_settings())
            ##            ev3_rpi_ctrl_pkg.messageSendX(EV3)   # DELETE FOR DEBUGGING
            ##            print('*** Enter messageSendY')
            ##            ev3_rpi_ctrl_pkg.messageSendY(m)     # DELETE FOR DEBUGGING
            ##            ev3_rpi_ctrl_pkg.messageSend(EV3, m) # send converted message # DUPLICXATE OF BELOW
            if EV3 is not None and EV3.isOpen() is True:
                print('\n -> Sending to EV3 msg: {} \n'.format(ev3Msg))
                print('*** ENTERING messageSend')
                ev3_rpi_ctrl_pkg.messageSend(EV3, m)  # send converted message
            else:
                print("\n  Can't send--EV3 is not open \n")
        elif text == 'ev3 open' or text == 'open ev3' or text == 'open lego' or text == 'lego open':
            EV3, ev3Port = open_connected_ev3()  # Try to open the EV3
            ##            print('**** Returned from open_connected_ev3()')
            if EV3 is not None:
                aiy.audio.say('EV3 has been opened')
                ##                print('**** EV3 type',type(EV3))
                ##                print('**** EV3 name',EV3.name)
                print('-> EV3 Settings', EV3.get_settings())
            else:
                aiy.audio.say('EV3 has not been opened')
        elif text == 'exit':
            assistant.stop_conversation()
            exit_pi()
            return True  # Indicate that user asked that the conversation end

    elif event.type == EventType.ON_END_OF_UTTERANCE:
        status_ui.status('thinking')

    elif (event.type == EventType.ON_CONVERSATION_TURN_FINISHED
          or event.type == EventType.ON_CONVERSATION_TURN_TIMEOUT
          or event.type == EventType.ON_NO_RESPONSE):
        status_ui.status('ready')

    elif event.type == EventType.ON_ASSISTANT_ERROR and event.args and event.args[
            'is_fatal']:
        sys.exit(1)
def process_event(assistant, led, event):
    # Function returns a Boolean.  True means user asked the conversation to end; false otherwise

    global EV3  # THis is the pointer to the LEGO EV3

    logging.info(event)
    if event.type == EventType.ON_START_FINISHED:
        led.state = Led.BEACON_DARK  # Ready.
        print('Say "OK, Google" then speak, or press Ctrl+C to quit...')
    elif event.type == EventType.ON_CONVERSATION_TURN_STARTED:
        led.state = Led.ON  # Listening.
    elif event.type == EventType.ON_RECOGNIZING_SPEECH_FINISHED and event.args:
        print('You said:', event.args['text'])
        text = event.args['text'].lower()
        if text == 'power off':
            assistant.stop_conversation()
            power_off_pi()
        elif text == 'reboot':
            assistant.stop_conversation()
            reboot_pi()
        elif text == 'ip address':
            assistant.stop_conversation()
            say_ip()
        elif text == 'ev3 forward' or text == 'lego forward':
            ev3Msg = "FWD"
            print('*** ENTERING messageGuin')
            m = ev3_rpi_ctrl_pkg.messageGuin(
                "EV3-CMD", ev3Msg,
                "text")  #  convert message; select EV3-CMD block to send to
            ##            print('*** EV3 is {}; EV3.isOpen() is {}'.format(EV3))
            ##            print('*** EV3.isOpen() is {}'.format(EV3.isOpen()))
            print('*** After messageGuin() \n *** Enter messageSendX')
            print('-> EV3 Settings', EV3.get_settings())
            ##            ev3_rpi_ctrl_pkg.messageSendX(EV3)   # DELETE FOR DEBUGGING
            ##            print('*** Enter messageSendY')
            ##            ev3_rpi_ctrl_pkg.messageSendY(m)     # DELETE FOR DEBUGGING
            ##            ev3_rpi_ctrl_pkg.messageSend(EV3, m) # send converted message # DUPLICXATE OF BELOW
            if EV3 is not None and EV3.isOpen() is True:
                print('\n -> Sending to EV3 msg: {} \n'.format(ev3Msg))
                print('*** ENTERING messageSend')
                ev3_rpi_ctrl_pkg.messageSend(EV3, m)  # send converted message
            else:
                print("\n  Can't send--EV3 is not open \n")
        elif text == 'ev3 open' or text == 'open ev3' or text == 'open lego' or text == 'lego open':
            EV3, ev3Port = open_connected_ev3()  # Try to open the EV3
            print('**** Returned from open_connected_ev3()')
            if EV3 is not None:
                tts.say('EV3 has been opened')
                print('**** EV3 type', type(EV3))
                print('**** EV3 name', EV3.name)
                print('-> EV3 Settings', EV3.get_settings())
            else:
                tts.say('EV3 has not been opened')
        elif text == 'exit':
            assistant.stop_conversation()
            exit_pi()
            return True  # Indicate that user asked that the conversation end

    elif event.type == EventType.ON_END_OF_UTTERANCE:
        led.state = Led.PULSE_QUICK  # Thinking.
    elif (event.type == EventType.ON_CONVERSATION_TURN_FINISHED
          or event.type == EventType.ON_CONVERSATION_TURN_TIMEOUT
          or event.type == EventType.ON_NO_RESPONSE):
        led.state = Led.BEACON_DARK  # Ready.
    elif event.type == EventType.ON_ASSISTANT_ERROR and event.args and event.args[
            'is_fatal']:
        sys.exit(1)

    return False  # User DID NOT ask for conversation to end