Example #1
0
    def passive_recognize(self):

        while self.running:
            try:
                if self.active:
                    print("Activated")

                    self.playback.play_high_beep()
                    discover_matrix().unpause()  # todo test

                    print("Waiting for input...")

                    data = self.get_segments()
                    # todo only continue if there's enough data
                    if data is None:
                        break

                    self.recognize(data)

                    self.passive = True
                    self.active = False
                    print("Switching to passive...")
                elif self.passive:
                    print("Recording for julius")
                    data = self.get_segments()
                    if data is None:
                        break

                    print("Sending audio to julius")
                    # todo stuck in here
                    self.julius.send_audio(data)
                    print("Finished")

                    self.active = self.is_activated(data)
                    if self.active:
                        self.passive = False
                else:
                    print "Hmm"
                    print "Passive " + str(self.passive)
                    print "Active " + str(self.active)

            except KeyboardInterrupt:
                break
Example #2
0
    def recognize(self, data):

        print("Recognizing input...")

        try:
            text = str(self.recognizer.recognize(data, show_all=True))
            print("You said: " + text)
            # self.playback.play_tts(text)
        except LookupError as e:
            self.playback.play_low_beep()
            text = e.message

        try:
            self.modules.handle(text)
        except Exception as e:
            print("Unexpected error in module: " + e.message)

        discover_matrix().pause()  # todo test

        return True
Example #3
0
 def handle(self, words):
     if "next" in words:
         discover_matrix().menu_next()  # todo test
     elif "previous" in words:
         discover_matrix().menu_previous()  # todo test