diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2014-09-26 16:58:07 +0200 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2014-09-26 16:58:07 +0200 |
| commit | cb0eb4742347c7d8c692342bc4c0e37a95ffaa51 (patch) | |
| tree | aef2f60d1f446f4ebd296f7c6597a2dca06747fb /client/conversation.py | |
| parent | ba7df0c17b633e28502db384743856f050d934c0 (diff) | |
| parent | dd133d3738162e184f206d112ea4a39ba43f0781 (diff) | |
| download | jasper-client-cb0eb4742347c7d8c692342bc4c0e37a95ffaa51.tar.gz jasper-client-cb0eb4742347c7d8c692342bc4c0e37a95ffaa51.zip | |
Merge pull request #148 from alexsiri7/multiple_queries
Handle all Google Speech options
Diffstat (limited to 'client/conversation.py')
| -rw-r--r-- | client/conversation.py | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/client/conversation.py b/client/conversation.py index be9b8e9..8ec912c 100644 --- a/client/conversation.py +++ b/client/conversation.py @@ -14,28 +14,29 @@ class Conversation(object): self.brain = Brain(mic, profile) self.notifier = Notifier(profile) - def delegateInput(self, text): + def delegateInput(self, texts): """A wrapper for querying brain.""" # check if input is meant to start the music module - if any(x in text.upper() for x in ["SPOTIFY", "MUSIC"]): - # check if mpd client is running - try: - client = MPDClient() - client.timeout = None - client.idletimeout = None - client.connect("localhost", 6600) - except: - self.mic.say( - "I'm sorry. It seems that Spotify is not enabled. Please read the documentation to learn how to configure Spotify.") - return + for text in texts: + if any(x in text.upper() for x in ["SPOTIFY", "MUSIC"]): + # check if mpd client is running + try: + client = MPDClient() + client.timeout = None + client.idletimeout = None + client.connect("localhost", 6600) + except: + self.mic.say( + "I'm sorry. It seems that Spotify is not enabled. Please read the documentation to learn how to configure Spotify.") + return - self.mic.say("Please give me a moment, I'm loading your Spotify playlists.") - music_mode = MusicMode(self.persona, self.mic) - music_mode.handleForever() - return + self.mic.say("Please give me a moment, I'm loading your Spotify playlists.") + music_mode = MusicMode(self.persona, self.mic) + music_mode.handleForever() + return - self.brain.query(text) + self.brain.query(texts) def handleForever(self): """Delegates user input to the handling function when activated.""" @@ -50,7 +51,7 @@ class Conversation(object): if not transcribed or not threshold: continue - input = self.mic.activeListen(threshold) + input = self.mic.activeListenToAllOptions(threshold) if input: self.delegateInput(input) else: |
