예제 #1
0
    def run(self) -> None:
        self.greet()

        while True:
            if self.stop:
                break

            try:
                if stt.listen_for_keyword():
                    log.debug("Back in main loop...")

                    audio = stt.listen()
                    audio_input = stt.recognize(audio)

                    if not audio_input:
                        log.info("Couldn't resolve audio...")
                        continue
                    else:
                        log.info("Catched input: '{0}'".format(audio_input))

                    cmd = matching.get_match(audio_input)

                    matching.execute_match(cmd)
            except KeyboardInterrupt:
                log.info("Detected keyboard interruption...")
                self.quit()
                break
            except:
                log.error("Unexpected error...")
                traceback.print_exc()

                # sends the traceback to Sentry
                capture_exception(traceback.print_exc())
                break
예제 #2
0
    def test_cmd_google_news() -> None:
        mock_input = "tell me the news"
        expected_match = {"name": "news", "text": mock_input, "input": mock_input}

        matched_cmd = matching.get_match(mock_input)

        print_results(mock_input, matched_cmd, expected_match)

        assert matched_cmd == expected_match
예제 #3
0
    def test_cmd_echo() -> None:
        mock_input = "repeat testing"
        expected_match = {"name": "echo", "text": "repeat", "input": mock_input}

        matched_cmd = matching.get_match(mock_input)

        print_results(mock_input, matched_cmd, expected_match)

        assert matched_cmd == expected_match
예제 #4
0
    def test_cmd_about_me() -> None:
        mock_input = "who are you"
        expected_match = {"name": "me_info", "text": mock_input, "input": mock_input}

        matched_cmd = matching.get_match(mock_input)

        print_results(mock_input, matched_cmd, expected_match)

        assert matched_cmd == expected_match
예제 #5
0
    def test_cmd_time() -> None:
        mock_input = "what's the time"
        expected_match = {"name": "time", "text": mock_input, "input": mock_input}

        matched_cmd = matching.get_match(mock_input)

        print_results(mock_input, matched_cmd, expected_match)

        assert matched_cmd == expected_match
예제 #6
0
    def test_cmd_commands() -> None:
        mock_input = "the commands"
        expected_match = {"name": "commands", "text": mock_input, "input": mock_input}

        matched_cmd = matching.get_match(mock_input)

        print_results(mock_input, matched_cmd, expected_match)

        assert matched_cmd == expected_match
예제 #7
0
    def test_cmd_coronavirus() -> None:
        mock_input = "covid cases"
        expected_match = {"name": "covid", "text": mock_input, "input": mock_input}

        matched_cmd = matching.get_match(mock_input)

        print_results(mock_input, matched_cmd, expected_match)

        assert matched_cmd == expected_match
예제 #8
0
    def test_cmd_note_clear() -> None:
        mock_input = "clear my notes"
        expected_match = {"name": "note_clear", "text": mock_input, "input": mock_input}

        matched_cmd = matching.get_match(mock_input)

        print_results(mock_input, matched_cmd, expected_match)

        assert matched_cmd == expected_match
예제 #9
0
    def test_cmd_note_add() -> None:
        mock_input = "new note i'm testing"
        expected_match = {"name": "note_add", "text": "new note", "input": mock_input}

        matched_cmd = matching.get_match(mock_input)

        print_results(mock_input, matched_cmd, expected_match)

        assert matched_cmd == expected_match
예제 #10
0
        def test_cmd_google_search() -> None:
            mock_input = "how old is Elon Musk"
            expected_match = {
                "name": "google_search",
                "text": mock_input,
                "input": mock_input,
            }

            matched_cmd = matching.get_match(mock_input)

            print_results(mock_input, matched_cmd, expected_match)

            assert matched_cmd == expected_match
예제 #11
0
    def test_cmd_register_install() -> None:
        mock_input = "register install"
        expected_match = {
            "name": "register_install",
            "text": mock_input,
            "input": mock_input,
        }

        matched_cmd = matching.get_match(mock_input)

        print_results(mock_input, matched_cmd, expected_match)

        assert matched_cmd == expected_match