2016-08-28 8 views
3

私はオーディオをテキストに変換する必要がある作業を開始しています。私はpythonの音声認識ライブラリを使用しています。私はgithubの使い方のチュートリアルを見ました。このプログラムは、マイクを通して私の声を認識することはできません。ubuntuで音声認識が機能しない

私はubuntu 16.04でpython 2.7を使用しています。

コード:端末上

import speech_recognition as sr 

# obtain audio from the microphone 
r = sr.Recognizer() 
with sr.Microphone() as source: 
    print("Say something!") 
    r.adjust_for_ambient_noise(source) 
    audio = r.listen(source) 

# recognize speech using Sphinx 
try: 
    print("Sphinx thinks you said " + r.recognize_sphinx(audio)) 
except sr.UnknownValueError: 
    print("Sphinx could not understand audio") 
except sr.RequestError as e: 
    print("Sphinx error; {0}".format(e)) 

github code link

出力:後

[email protected]:~/Python/audio$ python temp.py 
ALSA lib pcm_dsnoop.c:606:(snd_pcm_dsnoop_open) unable to open slave 
ALSA lib pcm_dmix.c:1029:(snd_pcm_dmix_open) unable to open slave 
ALSA lib pcm_dmix.c:1029:(snd_pcm_dmix_open) unable to open slave 
Say something! 

、 "何かを言う!"、それが点滅し続けているが、私の声が認識されません。

mic settings

+1

alsa行は、ミキサーなどを制御できないことを示唆しています。おそらく、オペレーティングシステムのバージョン、Pythonのバージョン、そしてこれをsshセッション、ローカルコンピュータ上のX11ターミナル、または何で実行しているのかを伝えるべきでしょう。 –

+1

@AnttiHaapala ubuntu 16.04、python 2.7、ローカルコンピュータ上の端末。 –

+0

それは私のために働いた、私は何かを言って、数秒後に出力を印刷した。私はあなたがあなたのマイクをミュートしていると信じています、そして、それらのALSAの警告(私もあまりにも)は音量レベルを変えようとしましたが、失敗しました。 Ubuntuのサウンド設定とalsamixerの両方をチェックする必要があります。 –

答えて

0

私が問題に実行して、PocketSphinxモジュールがインストールされ得ることができませんでした。 しかし、recognize_sphinxrecognize_googleに切り替えると、私のために働いています。

ここにあなたの変更されたコードがあります。

import speech_recognition as sr 

# obtain audio from the microphone 
r = sr.Recognizer() 
with sr.Microphone() as source: 
    print("Say something!") 
    r.adjust_for_ambient_noise(source) 
    audio = r.listen(source) 

# recognize speech using Sphinx 
try: 
    #print("Sphinx thinks you said " + r.recognize_sphinx(audio)) 
    print("Sphinx thinks you said " + r.recognize_google(audio)) 
except sr.UnknownValueError: 
    print("Sphinx could not understand audio") 
except sr.RequestError as e: 
    print("Sphinx error; {0}".format(e)) 

出力

Python 2.7.9 (default, Dec 10 2014, 12:24:55) [MSC v.1500 32 bit (Intel)] on win32 
Type "copyright", "credits" or "license()" for more information. 
>>> ================================ RESTART ================================ 
>>> 
Say something! 
Sphinx thinks you said hello 
>>> 

希望はこれが便利です。

+0

今、「何か」が画面に表示されない場合もあります。私はpulseaudioとjack2をインストールしました。 –