コード例 #1
0
ファイル: test_stt.py プロジェクト: badcons2002/mycroft
    def test_ibm_stt(self, mock_get, mock_post):
        import json

        config = base_config()
        config.merge({
            'stt': {
                'module': 'ibm',
                'ibm': {
                    'credential': {
                        'token': 'FOOBAR'
                    },
                    'url': 'https://test.com'
                },
            },
            'lang': 'en-US'
        })
        mock_get.return_value = config

        requests_object = MagicMock()
        requests_object.status_code = 200
        requests_object.text = json.dumps({
            'results': [{
                'alternatives': [{
                    'confidence': 0.96,
                    'transcript': 'sample response'
                }],
                'final':
                True
            }],
            'result_index':
            0
        })
        mock_post.return_value = requests_object

        audio = MagicMock()
        audio.sample_rate = 16000

        stt = mycroft.stt.IBMSTT()
        stt.execute(audio)

        test_url_base = 'https://test.com/v1/recognize'
        mock_post.assert_called_with(test_url_base,
                                     auth=('apikey', 'FOOBAR'),
                                     headers={
                                         'Content-Type': 'audio/x-flac',
                                         'X-Watson-Learning-Opt-Out': 'true'
                                     },
                                     data=audio.get_flac_data(),
                                     params={
                                         'model': 'en-US_BroadbandModel',
                                         'profanity_filter': 'false'
                                     })
コード例 #2
0
ファイル: test_stt.py プロジェクト: aatchison/mycroft-core
    def test_wit_stt(self, mock_get):
        mycroft.stt.Recognizer = mock.MagicMock
        config = {'stt': {
                 'module': 'wit',
                 'wit': {'credential': {'token': 'FOOBAR'}},
            },
            "lang": "en-US"
        }
        mock_get.return_value = config

        audio = mock.MagicMock()
        stt = mycroft.stt.WITSTT()
        stt.execute(audio)
        self.assertTrue(stt.recognizer.recognize_wit.called)
コード例 #3
0
ファイル: test_stt.py プロジェクト: aatchison/mycroft-core
    def test_mycroft_stt(self, mock_get):
        mycroft.stt.STTApi = mock.MagicMock()
        config = {'stt': {
                 'module': 'mycroft',
                 'mycroft': {'uri': 'https://test.com'}
            },
            'lang': 'en-US'
        }
        mock_get.return_value = config

        stt = mycroft.stt.MycroftSTT()
        audio = mock.MagicMock()
        stt.execute(audio, 'en-us')
        self.assertTrue(mycroft.stt.STTApi.called)
コード例 #4
0
    def test_mycroft_stt(self, mock_get):
        mycroft.stt.STTApi = mock.MagicMock()
        config = {'stt': {
                 'module': 'mycroft',
                 'mycroft': {'uri': 'https://test.com'}
            },
            'lang': 'en-US'
        }
        mock_get.return_value = config

        stt = mycroft.stt.MycroftSTT()
        audio = mock.MagicMock()
        stt.execute(audio, 'en-us')
        self.assertTrue(mycroft.stt.STTApi.called)
コード例 #5
0
    def test_google_stt(self, mock_get):
        mycroft.stt.Recognizer = mock.MagicMock
        config = {'stt': {
                 'module': 'google',
                 'google': {'credential': {'token': 'FOOBAR'}},
            },
            "lang": "en-US"
        }
        mock_get.return_value = config

        audio = mock.MagicMock()
        stt = mycroft.stt.GoogleSTT()
        stt.execute(audio)
        self.assertTrue(stt.recognizer.recognize_google.called)
コード例 #6
0
ファイル: test_stt.py プロジェクト: Ceda-EI/mycroft-core
    def test_houndify_stt(self, mock_get):
        mycroft.stt.Recognizer = mock.MagicMock
        config = {'stt': {
            'module': 'houndify',
            'houndify': {'credential': {'client_id': 'FOO',
                                        "client_key": "BAR"}}
        },
            "lang": "en-US"
        }
        mock_get.return_value = config

        audio = mock.MagicMock()
        stt = mycroft.stt.HoundifySTT()
        stt.execute(audio)
        self.assertTrue(stt.recognizer.recognize_houndify.called)
コード例 #7
0
ファイル: test_stt.py プロジェクト: Ceda-EI/mycroft-core
    def test_ibm_stt(self, mock_get):
        mycroft.stt.Recognizer = mock.MagicMock
        config = {'stt': {
                  'module': 'ibm',
                  'ibm': {'credential': {'username': '******',
                                         "password": '******'}},
                  },
                  "lang": "en-US"
                  }
        mock_get.return_value = config

        audio = mock.MagicMock()
        stt = mycroft.stt.IBMSTT()
        stt.execute(audio)
        self.assertTrue(stt.recognizer.recognize_ibm.called)
コード例 #8
0
    def test_kaldi_stt(self, mock_get, mock_post):
        mycroft.stt.Recognizer = mock.MagicMock
        config = {
            'stt': {
                'module': 'kaldi',
                'kaldi': {
                    'uri': 'https://test.com'
                },
            },
            "lang": "en-US"
        }
        mock_get.return_value = config

        kaldiResponse = mock.MagicMock()
        kaldiResponse.json.return_value = {
            'hypotheses': [{
                'utterance': '     [noise]     text'
            }, {
                'utterance': '     asdf'
            }]
        }
        mock_post.return_value = kaldiResponse
        audio = mock.MagicMock()
        stt = mycroft.stt.KaldiSTT()
        self.assertEquals(stt.execute(audio), 'text')
コード例 #9
0
ファイル: test_stt.py プロジェクト: Dark5ide/mycroft-core
    def test_bing_stt(self, mock_get):
        mycroft.stt.Recognizer = mock.MagicMock
        config = base_config()
        config.merge(
            {
                'stt': {
                    'module': 'bing',
                    'bing': {'credential': {'token': 'FOOBAR'}},
                },
                'lang': 'en-US'
            })
        mock_get.return_value = config

        audio = mock.MagicMock()
        stt = mycroft.stt.BingSTT()
        stt.execute(audio)
        self.assertTrue(stt.recognizer.recognize_bing.called)
コード例 #10
0
ファイル: test_stt.py プロジェクト: Ceda-EI/mycroft-core
    def test_google_cloud_stt(self, mock_get):
        mycroft.stt.Recognizer = mock.MagicMock
        config = {'stt': {
                 'module': 'google_cloud',
                 'google_cloud': {
                   'credential': {
                     'json': {}
                   }
                 },
            },
            "lang": "en-US"
        }
        mock_get.return_value = config

        audio = mock.MagicMock()
        stt = mycroft.stt.GoogleCloudSTT()
        stt.execute(audio)
        self.assertTrue(stt.recognizer.recognize_google_cloud.called)
コード例 #11
0
ファイル: test_stt.py プロジェクト: Dark5ide/mycroft-core
    def test_ibm_stt(self, mock_get):
        mycroft.stt.Recognizer = mock.MagicMock
        config = base_config()
        config.merge(
            {
                'stt': {
                    'module': 'ibm',
                    'ibm': {
                        'credential': {'username': '******', 'password': '******'}
                    },
                },
                'lang': 'en-US'
            })
        mock_get.return_value = config

        audio = mock.MagicMock()
        stt = mycroft.stt.IBMSTT()
        stt.execute(audio)
        self.assertTrue(stt.recognizer.recognize_ibm.called)
コード例 #12
0
ファイル: test_stt.py プロジェクト: hungnt1/core
    def test_houndify_stt(self, mock_get):
        mycroft.stt.Recognizer = mock.MagicMock
        config = {
            'stt': {
                'module': 'houndify',
                'houndify': {
                    'credential': {
                        'client_id': 'FOO',
                        "client_key": "BAR"
                    }
                }
            },
            "lang": "en-US"
        }
        mock_get.return_value = config

        audio = mock.MagicMock()
        stt = mycroft.stt.HoundifySTT()
        stt.execute(audio)
        self.assertTrue(stt.recognizer.recognize_houndify.called)
コード例 #13
0
ファイル: test_stt.py プロジェクト: maxo2/mycroft
    def test_google_cloud_stt(self, mock_get):
        mycroft.stt.Recognizer = mock.MagicMock
        config = base_config()
        config.merge({
            'stt': {
                'module': 'google_cloud',
                'google_cloud': {
                    'credential': {
                        'json': {}
                    }
                },
            },
            'lang': 'en-US'
        })
        mock_get.return_value = config

        audio = mock.MagicMock()
        stt = mycroft.stt.GoogleCloudSTT()
        stt.execute(audio)
        self.assertTrue(stt.recognizer.recognize_google_cloud.called)
コード例 #14
0
ファイル: test_stt.py プロジェクト: maxo2/mycroft
    def test_bing_stt(self, mock_get):
        mycroft.stt.Recognizer = mock.MagicMock
        config = base_config()
        config.merge({
            'stt': {
                'module': 'bing',
                'bing': {
                    'credential': {
                        'token': 'FOOBAR'
                    }
                },
            },
            'lang': 'en-US'
        })
        mock_get.return_value = config

        audio = mock.MagicMock()
        stt = mycroft.stt.BingSTT()
        stt.execute(audio)
        self.assertTrue(stt.recognizer.recognize_bing.called)
コード例 #15
0
ファイル: test_stt.py プロジェクト: hungnt1/core
    def test_ibm_stt(self, mock_get):
        mycroft.stt.Recognizer = mock.MagicMock
        config = {
            'stt': {
                'module': 'ibm',
                'ibm': {
                    'credential': {
                        'username': '******',
                        "password": '******'
                    }
                },
            },
            "lang": "en-US"
        }
        mock_get.return_value = config

        audio = mock.MagicMock()
        stt = mycroft.stt.IBMSTT()
        stt.execute(audio)
        self.assertTrue(stt.recognizer.recognize_ibm.called)
コード例 #16
0
ファイル: test_stt.py プロジェクト: maxo2/mycroft
    def test_ibm_stt(self, mock_get):
        mycroft.stt.Recognizer = mock.MagicMock
        config = base_config()
        config.merge({
            'stt': {
                'module': 'ibm',
                'ibm': {
                    'credential': {
                        'username': '******',
                        'password': '******'
                    }
                },
            },
            'lang': 'en-US'
        })
        mock_get.return_value = config

        audio = mock.MagicMock()
        stt = mycroft.stt.IBMSTT()
        stt.execute(audio)
        self.assertTrue(stt.recognizer.recognize_ibm.called)
コード例 #17
0
ファイル: test_stt.py プロジェクト: badcons2002/mycroft
    def test_houndify_stt(self, mock_get):
        mycroft.stt.Recognizer = MagicMock
        config = base_config()
        config.merge({
            'stt': {
                'module': 'houndify',
                'houndify': {
                    'credential': {
                        'client_id': 'FOO',
                        'client_key': "BAR"
                    }
                }
            },
            'lang': 'en-US'
        })
        mock_get.return_value = config

        audio = MagicMock()
        stt = mycroft.stt.HoundifySTT()
        stt.execute(audio)
        self.assertTrue(stt.recognizer.recognize_houndify.called)
コード例 #18
0
ファイル: test_stt.py プロジェクト: aatchison/mycroft-core
    def test_kaldi_stt(self, mock_get, mock_post):
        mycroft.stt.Recognizer = mock.MagicMock
        config = {'stt': {
                 'module': 'kaldi',
                 'kaldi': {'uri': 'https://test.com'},
            },
            "lang": "en-US"
        }
        mock_get.return_value = config

        kaldiResponse = mock.MagicMock()
        kaldiResponse.json.return_value = {
                'hypotheses': [{'utterance': '     [noise]     text'},
                               {'utterance': '     asdf'}]
        }
        mock_post.return_value = kaldiResponse
        audio = mock.MagicMock()
        stt = mycroft.stt.KaldiSTT()
        self.assertEquals(stt.execute(audio), 'text')