def test_recognize(key, filename): """ Microsoft Bing Speech APIを使って音声認識するテスト用関数 """ from audio import AudioData, AudioFile af = AudioFile(filename) af.__enter__() ad = AudioData( open(filename, 'rb').read(), af.SAMPLE_RATE, af.SAMPLE_WIDTH) bs = Bing() r = bs.recognize(ad, key=key, show_all=True) print(r)
def test_recognize(key, filename): """ Google Cloud Speech APIを使って音声認識するテスト用関数 """ from audio import AudioData, AudioFile af = AudioFile(filename) af.__enter__() ad = AudioData( open(filename, 'rb').read(), af.SAMPLE_RATE, af.SAMPLE_WIDTH) gs = Google() r = gs.recognize(ad, key=key, show_all=True) print(r)