assistant.google.pushtotalk
Platypush documentation
assistant.google.pushtotalk
- class platypush.plugins.assistant.google.pushtotalk.AssistantGooglePushtotalkPlugin(credentials_file='/home/blacklight/.config/google-oauthlib-tool/credentials.json', device_config='/home/blacklight/.config/googlesamples-assistant/device_config.json', language='en-US', play_response=True, tts_plugin=None, tts_args=None, **kwargs)[source]
Bases:
AssistantPlugin
Plugin for the Google Assistant push-to-talk API.
Triggers:
platypush.message.event.assistant.ConversationStartEvent
when a new conversation starts
platypush.message.event.assistant.SpeechRecognizedEvent
when a new voice command is recognized
platypush.message.event.assistant.ConversationEndEvent
when a new conversation ends
Requires:
tenacity (
pip install tenacity
)google-assistant-sdk (
pip install google-assistant-sdk[samples]
)
- __init__(credentials_file='/home/blacklight/.config/google-oauthlib-tool/credentials.json', device_config='/home/blacklight/.config/googlesamples-assistant/device_config.json', language='en-US', play_response=True, tts_plugin=None, tts_args=None, **kwargs)[source]
- Parameters:
credentials_file (str) – Path to the Google OAuth credentials file (default: ~/.config/google-oauthlib-tool/credentials.json). See https://developers.google.com/assistant/sdk/guides/library/python/embed/install-sample#generate_credentials for instructions to get your own credentials file.
device_config (str) – Path to device_config.json. Register your device (see https://developers.google.com/assistant/sdk/guides/library/python/embed/register-device) and create a project, then run the pushtotalk.py script from googlesamples to create your device_config.json
language (str) – Assistant language (default: en-US)
play_response (bool) – If True (default) then the plugin will play the assistant response upon processed response. Otherwise nothing will be played - but you may want to handle the
ResponseEvent
manually.tts_plugin (str) – Optional text-to-speech plugin to be used to process response text.
tts_args (dict) – Optional arguments for the TTS plugin
say
method.
- set_mic_mute(muted: bool = True)[source]
Programmatically mute/unmute the microphone.
- Parameters:
muted – Set to True or False.
- start_conversation(*args, language: Optional[str] = None, tts_plugin: Optional[str] = None, tts_args: Optional[Dict[str, Any]] = None, **kwargs)[source]
Start a conversation
- Parameters:
language – Language code override (default: default configured language).
tts_plugin – Optional text-to-speech plugin to be used for rendering text.
tts_args – Optional arguments for the TTS plugin say method.
- Returns:
A list of the interactions that happen within the conversation.
[ { "request": "request 1", "response": "response 1" }, { "request": "request 2", "response": "response 2" } ]