From fe42407497f4f3dcc1388f2e9da53dd64ccf6382 Mon Sep 17 00:00:00 2001 From: schneefux Date: Wed, 1 Oct 2014 14:47:29 +0200 Subject: Apply fix from PR jasperproject/jasper-client#173 to MusicMode --- client/modules/MPDControl.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/client/modules/MPDControl.py b/client/modules/MPDControl.py index 778fe5c..7d79174 100644 --- a/client/modules/MPDControl.py +++ b/client/modules/MPDControl.py @@ -62,6 +62,7 @@ def isValid(text): class MusicMode(object): def __init__(self, PERSONA, mic, mpdwrapper): + self._logger = logging.getLogger(__name__) self.persona = PERSONA # self.mic - we're actually going to ignore the mic they passed in self.music = mpdwrapper @@ -175,26 +176,25 @@ class MusicMode(object): while True: - try: - threshold, transcribed = self.mic.passiveListen(self.persona) - except: - continue + threshold, transcribed = self.mic.passiveListen(self.persona) - if threshold: + if not transcribed or not threshold: + self._logger.info("Nothing has been said or transcribed.") + continue - self.music.pause() + self.music.pause() - input = self.mic.activeListen(MUSIC=True) + input = self.mic.activeListen(MUSIC=True) - if "close" in input.lower(): - self.mic.say("Closing Spotify") - return + if "close" in input.lower(): + self.mic.say("Closing Spotify") + return - if input: - self.delegateInput(input) - else: - self.mic.say("Pardon?") - self.music.play() + if input: + self.delegateInput(input) + else: + self.mic.say("Pardon?") + self.music.play() def reconnect(func, *default_args, **default_kwargs): """ -- cgit v1.3.1