diff --git a/src/main.py b/src/main.py index 1cfe45b7..b115ad4b 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,9 +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'] + 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: @@ -389,7 +398,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 @@ -554,6 +563,15 @@ def process_response(response): logger.debug("new volume = %s", volume) + ''' + This causes a deadlock on triggers + ### 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'])