push_red_to_talk.py
def converse(self):
        """Send a voice request to the Assistant and playback the response.

        Returns: True if conversation should continue.
        """
        continue_conversation = False

        self.conversation_stream.start_recording()
        red_breathing_led.start_breathing()
        logging.info('Recording audio request.')

        def iter_converse_requests():
            for c in self.gen_converse_requests():
                assistant_helpers.log_converse_request_without_audio(c)
                yield c

            self.conversation_stream.start_playback()

        # This generator yields ConverseResponse proto messages
        # received from the gRPC Google Assistant API.
        for resp in self.assistant.Converse(iter_converse_requests(), self.deadline):
            assistant_helpers.log_converse_response_without_audio(resp)
            if resp.error.code != code_pb2.OK:
                logging.error('server error: %s', resp.error.message)
                break
            if resp.event_type == END_OF_UTTERANCE:
                logging.info('End of audio request detected')
                self.conversation_stream.stop_recording()
                red_breathing_led.stop()
            if resp.result.spoken_request_text:
                self.print_spoken_request(resp)
            if len(resp.audio_out.audio_data) > 0:
                self.conversation_stream.write(resp.audio_out.audio_data)
            if resp.result.spoken_response_text:
                self.print_response(resp)
            if resp.result.conversation_state:
                self.conversation_state = resp.result.conversation_state
            if resp.result.volume_percentage != 0:
                self.conversation_stream.volume_percentage = (
                    resp.result.volume_percentage
                )
            if resp.result.microphone_mode == DIALOG_FOLLOW_ON:
                continue_conversation = True
                logging.info('Expecting follow-on query from user.')
            elif resp.result.microphone_mode == CLOSE_MICROPHONE:
                continue_conversation = False
        logging.info('Finished playing assistant response.')
        self.conversation_stream.stop_playback()
        return continue_conversation
Send a voice request to the Assistant and playback the response.

        Returns: True if conversation should continue.
        
Send a voice request to the Assistant and playback the response.
Returns: True if conversation should continue.
Send a voice request to the Assistant and playback the response . Returns : True if conversation should continue .
def converse(self):
        continue_conversation = False
        self.conversation_stream.start_recording()
        red_breathing_led.start_breathing()
        logging.info('Recording audio request.')
        def iter_converse_requests():
            for c in self.gen_converse_requests():
                assistant_helpers.log_converse_request_without_audio(c)
                yield c
            self.conversation_stream.start_playback()
        for resp in self.assistant.Converse(iter_converse_requests(), self.deadline):
            assistant_helpers.log_converse_response_without_audio(resp)
            if resp.error.code != code_pb2.OK:
                logging.error('server error: %s', resp.error.message)
                break
            if resp.event_type == END_OF_UTTERANCE:
                logging.info('End of audio request detected')
                self.conversation_stream.stop_recording()
                red_breathing_led.stop()
            if resp.result.spoken_request_text:
                self.print_spoken_request(resp)
            if len(resp.audio_out.audio_data) > 0:
                self.conversation_stream.write(resp.audio_out.audio_data)
            if resp.result.spoken_response_text:
                self.print_response(resp)
            if resp.result.conversation_state:
                self.conversation_state = resp.result.conversation_state
            if resp.result.volume_percentage != 0:
                self.conversation_stream.volume_percentage = (
                    resp.result.volume_percentage
                )
            if resp.result.microphone_mode == DIALOG_FOLLOW_ON:
                continue_conversation = True
                logging.info('Expecting follow-on query from user.')
            elif resp.result.microphone_mode == CLOSE_MICROPHONE:
                continue_conversation = False
        logging.info('Finished playing assistant response.')
        self.conversation_stream.stop_playback()
        return continue_conversation
def converse ( self ) : continue_conversation = False self . conversation_stream . start_recording ( ) red_breathing_led . start_breathing ( ) logging . info ( 'Recording audio request.' ) def iter_converse_requests ( ) : for c in self . gen_converse_requests ( ) : assistant_helpers . log_converse_request_without_audio ( c ) yield c self . conversation_stream . start_playback ( ) for resp in self . assistant . Converse ( iter_converse_requests ( ) , self . deadline ) : assistant_helpers . log_converse_response_without_audio ( resp ) if resp . error . code != code_pb2 . OK : logging . error ( 'server error: %s' , resp . error . message ) break if resp . event_type == END_OF_UTTERANCE : logging . info ( 'End of audio request detected' ) self . conversation_stream . stop_recording ( ) red_breathing_led . stop ( ) if resp . result . spoken_request_text : self . print_spoken_request ( resp ) if len ( resp . audio_out . audio_data ) > 0 : self . conversation_stream . write ( resp . audio_out . audio_data ) if resp . result . spoken_response_text : self . print_response ( resp ) if resp . result . conversation_state : self . conversation_state = resp . result . conversation_state if resp . result . volume_percentage != 0 : self . conversation_stream . volume_percentage = ( resp . result . volume_percentage ) if resp . result . microphone_mode == DIALOG_FOLLOW_ON : continue_conversation = True logging . info ( 'Expecting follow-on query from user.' ) elif resp . result . microphone_mode == CLOSE_MICROPHONE : continue_conversation = False logging . info ( 'Finished playing assistant response.' ) self . conversation_stream . stop_playback ( ) return continue_conversation
Send a voice request to the Assistant and playback the response.
Send a voice request to the Assistant and playback the response .
"""Send a voice request to the Assistant and playback the response.

        Returns: True if conversation should continue.
        """ # This generator yields ConverseResponse proto messages # received from the gRPC Google Assistant API.
self