From dd133d3738162e184f206d112ea4a39ba43f0781 Mon Sep 17 00:00:00 2001 From: schneefux Date: Sat, 30 Aug 2014 17:44:47 +0100 Subject: Handle all Google Speech options --- client/brain.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'client/brain.py') diff --git a/client/brain.py b/client/brain.py index f2a2efd..f57331c 100644 --- a/client/brain.py +++ b/client/brain.py @@ -42,7 +42,7 @@ class Brain(object): modules.sort(key=lambda mod: mod.PRIORITY if hasattr(mod, 'PRIORITY') else 0, reverse=True) return modules - def query(self, text): + def query(self, texts): """ Passes user input to the appropriate module, testing it against each candidate module's isValid function. @@ -51,13 +51,14 @@ class Brain(object): text -- user input, typically speech, to be parsed by a module """ for module in self.modules: - if module.isValid(text): - - try: - module.handle(text, self.mic, self.profile) - break - except: - self._logger.error('Failed to execute module', exc_info=True) - self.mic.say( - "I'm sorry. I had some trouble with that operation. Please try again later.") - break + for text in texts: + + if module.isValid(text): + try: + module.handle(text, self.mic, self.profile) + return + except: + self._logger.error('Failed to execute module', exc_info=True) + self.mic.say( + "I'm sorry. I had some trouble with that operation. Please try again later.") + return -- cgit v1.3.1