def iter_assist_requests():
     config = embedded_assistant_pb2.AssistConfig(
         audio_out_config=embedded_assistant_pb2.AudioOutConfig(
             encoding='LINEAR16',
             sample_rate_hertz=16000,
             volume_percentage=0,
         ),
         dialog_state_in=embedded_assistant_pb2.DialogStateIn(
             language_code=self.language_code,
             conversation_state=self.conversation_state,
             is_new_conversation=self.is_new_conversation,
         ),
         device_config=embedded_assistant_pb2.DeviceConfig(
             device_id=self.device_id,
             device_model_id=self.device_model_id,
         ),
         text_query=text_query,
     )
     # Continue current conversation with later requests.
     self.is_new_conversation = False
     if self.display:
         config.screen_out_config.screen_mode = PLAYING
     req = embedded_assistant_pb2.AssistRequest(config=config)
     # This can be used to output the assistant request
     # assistant_helpers.log_assist_request_without_audio(req)
     assistant_helpers.log_assist_request_without_audio(req)
     yield req
Exemplo n.º 2
0
 def iter_log_assist_requests():
     if (text_query):
         config = embedded_assistant_pb2.AssistConfig(
             audio_out_config=embedded_assistant_pb2.AudioOutConfig(
                 encoding='LINEAR16',
                 sample_rate_hertz=16000,
                 volume_percentage=0,
             ),
             dialog_state_in=embedded_assistant_pb2.DialogStateIn(
                 language_code=self.language_code,
                 conversation_state=self.conversation_state,
                 is_new_conversation=self.is_new_conversation,
             ),
             device_config=embedded_assistant_pb2.DeviceConfig(
                 device_id=self.device_id,
                 device_model_id=self.device_model_id,
             ),
             text_query=text_query,
         )
         self.is_new_conversation = False
         req = embedded_assistant_pb2.AssistRequest(config=config)
         assistant_helpers.log_assist_request_without_audio(req)
         yield req
     else:
         for c in self.gen_assist_requests():
             assistant_helpers.log_assist_request_without_audio(c)
             yield c
     logging.debug('Reached end of AssistRequest iteration.')
Exemplo n.º 3
0
    def gen_text_assist_requests(self, text_query):
        """Yields: AssistRequest messages to send to the API in text form"""

        config = embedded_assistant_pb2.AssistConfig(
            audio_out_config=embedded_assistant_pb2.AudioOutConfig(
                encoding='LINEAR16',
                sample_rate_hertz=self.conversation_stream.sample_rate,
                volume_percentage=self.conversation_stream.volume_percentage,
            ),
            dialog_state_in=embedded_assistant_pb2.DialogStateIn(
                language_code=self.language_code,
                conversation_state=self.conversation_state,
                is_new_conversation=self.is_new_conversation,
            ),
            device_config=embedded_assistant_pb2.DeviceConfig(
                device_id=self.device_id,
                device_model_id=self.device_model_id,
            ),
            text_query=text_query,
        )

        # Continue current conversation with later requests.
        self.is_new_conversation = False

        req = embedded_assistant_pb2.AssistRequest(config=config)
        assistant_helpers.log_assist_request_without_audio(req)
        yield req
Exemplo n.º 4
0
 def iter_assist_requests():
     dialog_state_in = embedded_assistant_pb2.DialogStateIn(
         language_code=self.language_code, conversation_state=b'')
     if self.conversation_state:
         dialog_state_in.conversation_state = self.conversation_state
     config = embedded_assistant_pb2.AssistConfig(
         audio_out_config=embedded_assistant_pb2.AudioOutConfig(
             encoding='LINEAR16',
             sample_rate_hertz=16000,
             volume_percentage=0,
         ),
         dialog_state_in=dialog_state_in,
         device_config=embedded_assistant_pb2.DeviceConfig(
             device_id=self.device_id,
             device_model_id=self.device_model_id,
         ),
         text_query=text_query,
     )
     req = embedded_assistant_pb2.AssistRequest(config=config)
     assistant_helpers.log_assist_request_without_audio(req)
     yield req
Exemplo n.º 5
0
 def iter_log_assist_requests():
     for c in self.gen_assist_requests():
         assistant_helpers.log_assist_request_without_audio(c)
         yield c
     logging.debug('Reached end of AssistRequest iteration.')
 def iter_assist_requests():
     for c in self.gen_assist_requests():
         assistant_helpers.log_assist_request_without_audio(c)
         yield c
     self.conversation_stream.start_playback()
Exemplo n.º 7
0
 def iter_log_assist_requests():
     for c in self.gen_assist_requests():
         assistant_helpers.log_assist_request_without_audio(c)
         yield c