diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2014-03-30 16:03:44 -0400 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2014-03-30 16:03:44 -0400 |
| commit | d31fabf8cff5dae02e3fc759a4203bd374dddc99 (patch) | |
| tree | 888ec4e6d98154f862a3b9cd17a3394b657bc02e /client/conversation.py | |
| parent | 4182b5e096e081158dddd4ad5d031af94fcc63de (diff) | |
| download | jasper-client-d31fabf8cff5dae02e3fc759a4203bd374dddc99.tar.gz jasper-client-d31fabf8cff5dae02e3fc759a4203bd374dddc99.zip | |
Initial commit
Diffstat (limited to 'client/conversation.py')
| -rwxr-xr-x | client/conversation.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/client/conversation.py b/client/conversation.py new file mode 100755 index 0000000..6e994a2 --- /dev/null +++ b/client/conversation.py @@ -0,0 +1,47 @@ +from notifier import Notifier +from musicmode import * +from brain import Brain + + +class Conversation(object): + + def __init__(self, persona, mic, profile): + self.persona = persona + self.mic = mic + self.profile = profile + self.brain = Brain(mic, profile) + self.notifier = Notifier(profile) + + def delegateInput(self, text): + """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"]): + 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) + + def handleForever(self): + """Delegates user input to the handling function when activated.""" + while True: + + # Print notifications until empty + notifications = self.notifier.getAllNotifications() + for notif in notifications: + print notif + + try: + threshold, transcribed = self.mic.passiveListen(self.persona) + except: + continue + + if threshold: + input = self.mic.activeListen(threshold) + if input: + self.delegateInput(input) + else: + self.mic.say("Pardon?") |
