From 3a3345139bdfb158e9d795321b47bd691b47c034 Mon Sep 17 00:00:00 2001 From: Martin Kainzbauer Date: Wed, 14 Jun 2017 14:46:33 +0200 Subject: [PATCH 1/2] resume playback after volume changing voice command --- src/main.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main.py b/src/main.py index 09afe13e..a36ee930 100755 --- a/src/main.py +++ b/src/main.py @@ -123,6 +123,10 @@ class Player(object): playlist_last_item = None progressReportRequired = [] + ### + last_playlist = None + ### + def __init__(self, config, platform, pHandler): # pylint: disable=redefined-outer-name self.config = config self.platform = platform @@ -130,6 +134,9 @@ def __init__(self, config, platform, pHandler): # pylint: disable=redefined-oute self.tunein_parser = tunein.TuneIn(5000) def play_playlist(self, payload): + ### + self.last_playlist = payload + ### self.navigation_token = payload['navigationToken'] self.playlist_last_item = payload['audioItem']['streams'][-1]['streamId'] @@ -341,10 +348,11 @@ def assistant_handler(voice_command): return False else: voice_command = voice_command.rstrip() - logger.debug('Pocketsphinx triggered with hotword: **' + voice_command + '**') + logger.debug('Triggered with hotword: **' + voice_command + '**') # compare to phrase_assistant from config voice_command_assistant = config['triggers']['pocketsphinx']['phrase_assistant'] - if voice_command in voice_command_assistant: + logger.debug('Google Assistant Hotword(s): ' + str(voice_command_assistant)) + if voice_command in voice_command_assistant: # works for both lists and strings global p if p is not None: # SDK is ready, start recording @@ -554,6 +562,12 @@ def process_response(response): logger.debug("new volume = %s", volume) + ### Resume playing the last station after setting volume + if player.last_playlist is not None: + player.play_playlist(player.last_playlist) + ### + + # Additional Audio Iten elif 'audioItem' in j['messageBody']: player.play_playlist(j['messageBody']) From e8e2dd68af7b81866b829275d39f0b3de0d07aee Mon Sep 17 00:00:00 2001 From: Martin Kainzbauer Date: Thu, 13 Jul 2017 21:00:41 +0200 Subject: [PATCH 2/2] fixed type in log message --- src/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.py b/src/main.py index a36ee930..2ec94187 100755 --- a/src/main.py +++ b/src/main.py @@ -397,7 +397,7 @@ def start_assistant(): else: flush_size = "" except: - logger.debug("Old configuration file without Assistant audio settings detected. To be able to adjust Google Adio settings, run setup again and create a new configuration.") + logger.debug("Old configuration file without Assistant audio settings detected. To be able to adjust Google Audio settings, run setup again and create a new configuration.") logger.debug("see also https://developers.google.com/assistant/sdk/prototype/getting-started-pi-python/troubleshooting") # Start Assistant SDK