New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get assistant response. #168

Closed
JakeMalis opened this Issue Jan 24, 2018 · 3 comments

Comments

Projects
None yet
2 participants
@JakeMalis

JakeMalis commented Jan 24, 2018

Can someone explain how I could get the assistant's response text on an external screen? Thanks.

@Fleker

This comment has been minimized.

Collaborator

Fleker commented Jan 25, 2018

You can use the pushtotalk sample to get the supplemental_display_text from the AssistResponse and then do what you want with that value.

@JakeMalis

This comment has been minimized.

JakeMalis commented Jan 25, 2018

With this code:

logging.info(DialogStateOut.supplemental_display_text)
self.conversation_stream.stop_playback()
return continue_conversation

I get this response:
WARNING:root:SoundDeviceStream read overflow (3200, 6400)
INFO:root:Transcript of user request: "what".
INFO:root:Playing assistant response.
INFO:root:Transcript of user request: "what time".
INFO:root:Playing assistant response.
INFO:root:Transcript of user request: "what time is".
INFO:root:Playing assistant response.
INFO:root:Transcript of user request: "what time is it".
INFO:root:Playing assistant response.
INFO:root:Transcript of user request: "what time is it".
INFO:root:Playing assistant response.
INFO:root:Transcript of user request: "what time is it".
INFO:root:Playing assistant response.
INFO:root:Transcript of user request: "what time is it".
INFO:root:Playing assistant response.
INFO:root:Transcript of user request: "what time is it".
INFO:root:Playing assistant response.
INFO:root:End of audio request detected
INFO:root:Transcript of user request: "what time is it".
INFO:root:Playing assistant response.
Traceback (most recent call last):
File "pushtotalk.py", line 435, in
main()
File "/home/pi/env/lib/python3.5/site-packages/click/core.py", line 722, in call
return self.main(*args, **kwargs)
File "/home/pi/env/lib/python3.5/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/home/pi/env/lib/python3.5/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/pi/env/lib/python3.5/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "pushtotalk.py", line 424, in main
continue_conversation = assistant.assist()
File "/home/pi/env/lib/python3.5/site-packages/tenacity/init.py", line 214, in wrapped_f
return self.call(f, *args, **kw)
File "/home/pi/env/lib/python3.5/site-packages/tenacity/init.py", line 295, in call
start_time=start_time)
File "/home/pi/env/lib/python3.5/site-packages/tenacity/init.py", line 252, in iter
return fut.result()
File "/usr/lib/python3.5/concurrent/futures/_base.py", line 398, in result
return self.__get_result()
File "/usr/lib/python3.5/concurrent/futures/_base.py", line 357, in __get_result
raise self._exception
File "/home/pi/env/lib/python3.5/site-packages/tenacity/init.py", line 298, in call
result = fn(*args, **kwargs)
File "pushtotalk.py", line 168, in assist
logging.info(DialogStateOut.supplemental_display_text)
NameError: name 'DialogStateOut' is not defined

P.S. why do I keep getting the "WARNING:root:SoundDeviceStream read overflow (3200, 6400)" error in the beginning even when I change the audio block number?

@Fleker

This comment has been minimized.

Collaborator

Fleker commented Jan 26, 2018

You need to take a look at the textinput sample.

    def assist(self, text_query):
        """Send a text request to the Assistant and playback the response.
        """
        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

        display_text = None
        for resp in self.assistant.Assist(iter_assist_requests(),
                                          self.deadline):
            assistant_helpers.log_assist_response_without_audio(resp)
            if resp.dialog_state_out.conversation_state:
                conversation_state = resp.dialog_state_out.conversation_state
                self.conversation_state = conversation_state
            if resp.dialog_state_out.supplemental_display_text:
                display_text = resp.dialog_state_out.supplemental_display_text
        return display_text

@Fleker Fleker closed this May 2, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment