From a2962d0970015b5b478b344fb2063f5304cccb59 Mon Sep 17 00:00:00 2001 From: schneefux Date: Fri, 26 Sep 2014 16:30:37 +0200 Subject: Add logging in conversation module --- client/conversation.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'client/conversation.py') diff --git a/client/conversation.py b/client/conversation.py index 8ec912c..003a700 100644 --- a/client/conversation.py +++ b/client/conversation.py @@ -1,4 +1,5 @@ # -*- coding: utf-8-*- +import logging from notifier import Notifier from musicmode import * from brain import Brain @@ -8,6 +9,7 @@ from mpd import MPDClient class Conversation(object): def __init__(self, persona, mic, profile): + self._logger = logging.getLogger(__name__) self.persona = persona self.mic = mic self.profile = profile @@ -20,6 +22,7 @@ class Conversation(object): # check if input is meant to start the music module for text in texts: if any(x in text.upper() for x in ["SPOTIFY", "MUSIC"]): + self._logger.debug("Preparing to start music module") # check if mpd client is running try: client = MPDClient() @@ -27,31 +30,41 @@ class Conversation(object): client.idletimeout = None client.connect("localhost", 6600) except: + self._logger.critical("Can't connect to mpd client, cannot start music mode.", exc_info=True) 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.") + self._logger.debug("Starting music mode") music_mode = MusicMode(self.persona, self.mic) music_mode.handleForever() + self._logger.debug("Exiting music mode") return self.brain.query(texts) def handleForever(self): """Delegates user input to the handling function when activated.""" + self._logger.info("Starting to handle conversation with keyword '%s'.", self.persona) while True: - # Print notifications until empty notifications = self.notifier.getAllNotifications() for notif in notifications: - print notif + self._logger.info("Got notification: '%s'", str(notif)) + self._logger.debug("Started listening for keyword '%s'", self.persona) threshold, transcribed = self.mic.passiveListen(self.persona) + self._logger.debug("Stopped listening for keyword '%s'", self.persona) + if not transcribed or not threshold: + self._logger.info("Nothing has been said or transcribed.") continue + self._logger.info("Keyword '%s' has been said!", self.persona) + self._logger.debug("Started to listen actively with threshold: %r", threshold) input = self.mic.activeListenToAllOptions(threshold) + self._logger.debug("Stopped to listen actively with threshold: %r", threshold) + if input: self.delegateInput(input) else: -- cgit v1.3.1 From a0a35dcf2159b60e6672eed5c74f238de5f61e4c Mon Sep 17 00:00:00 2001 From: schneefux Date: Tue, 30 Sep 2014 17:29:34 +0200 Subject: Readd missing line in conversation.py --- client/conversation.py | 1 + 1 file changed, 1 insertion(+) (limited to 'client/conversation.py') diff --git a/client/conversation.py b/client/conversation.py index 003a700..a5b2f8c 100644 --- a/client/conversation.py +++ b/client/conversation.py @@ -35,6 +35,7 @@ class Conversation(object): "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.") self._logger.debug("Starting music mode") music_mode = MusicMode(self.persona, self.mic) music_mode.handleForever() -- cgit v1.3.1 From 63f4a7c006d54c68a534f0910ed1cb601ed32edb Mon Sep 17 00:00:00 2001 From: schneefux Date: Wed, 1 Oct 2014 13:45:08 +0200 Subject: Change notification log message in conversation.py --- client/conversation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'client/conversation.py') diff --git a/client/conversation.py b/client/conversation.py index a5b2f8c..0746b7f 100644 --- a/client/conversation.py +++ b/client/conversation.py @@ -51,7 +51,7 @@ class Conversation(object): # Print notifications until empty notifications = self.notifier.getAllNotifications() for notif in notifications: - self._logger.info("Got notification: '%s'", str(notif)) + self._logger.info("Received notification: '%s'", str(notif)) self._logger.debug("Started listening for keyword '%s'", self.persona) threshold, transcribed = self.mic.passiveListen(self.persona) -- cgit v1.3.1