Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
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?")
Exemplo n.º 3
0
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("请重说")
Exemplo n.º 4
0
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?")
Exemplo n.º 5
0
 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)
Exemplo n.º 6
0
    def __init__(self, WakeWord: str, mic, config):

        self.logger = logging.getLogger(__name__)
        self.WakeWord = WakeWord
        self.config = config
        self.brain = Brain(mic, config)