def __init__(self, persona, mic, profile): self._logger = logging.getLogger(__name__) self.persona = persona self.mic = mic self.profile = profile self.brain = Brain(mic, profile) self.notifier = Notifier(profile)
class Conversation(object): def __init__(self, persona, mic, profile): self._logger = logging.getLogger(__name__) self.persona = persona self.mic = mic self.profile = profile self.brain = Brain(mic, profile) self.notifier = Notifier(profile) 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: 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) 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.brain.query(input) else: self.mic.say("Pardon?")
class Conversation(object): def __init__(self, persona, mic, profile): self._logger = logging.getLogger(__name__) self.persona = persona self.mic = mic self.profile = profile self.brain = Brain(mic, profile) 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: 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.activeListen() self._logger.debug("Stopped to listen actively with threshold: %r", threshold) if input: self.brain.query(input) else: self.mic.say("请重说")
class Conversation(object): def __init__(self, WakeWord: str, mic, config): self.logger = logging.getLogger(__name__) self.WakeWord = WakeWord self.config = config self.brain = Brain(mic, config) # self.notifier = Notifier(profile) def handleForever(self): self._logger.info( 'Starting to handle conversation with keyword {}'.format( self.WakeWord)) while True: #handle notifications from list here self._logger.info('Began listening for WakeWord') threshold, transcribed = self.mic.passiveListen(self.wakeWord) self._logger.info('Finished listening for WakeWord') if not transcribed or not threshold: self._logger.info( 'Volume was not above threshold or was not transcribed') self._logger.info('WakeWord was detected') 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.brain.query(input) else: self.mic.say("Pardon?")
def __init__(self, persona, mic, profile): self._logger = logging.getLogger(__name__) self.persona = persona self.mic = mic self.profile = profile self.brain = Brain(mic, profile)
def __init__(self, WakeWord: str, mic, config): self.logger = logging.getLogger(__name__) self.WakeWord = WakeWord self.config = config self.brain = Brain(mic, config)