2016-08-28 3 views
3

오디오를 텍스트로 변환해야하는 작업을 시작하고 있습니다. 파이썬의 speechrecognition 라이브러리를 사용하고 있습니다. 그것을 사용하는 방법에 github에 자습서를 보았다. 이 프로그램은 마이크를 통해 내 목소리를 알아볼 수있는 베일이 아닙니다.우분투에서 음성 인식이 작동하지 않습니다.

저는 우분투 16.04에서 파이썬 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 라인은 믹서 등을 제어 할 수 없다는 것을 암시합니다. 아마도 운영체제 버전, 파이썬 버전 및 ssh 세션, 로컬 컴퓨터의 X11 터미널 또는이 버전을 실행 중인지 여부를 알려줘야합니다. –

+1

@AnttiHaapala 우분투 16.04, 파이썬 2.7 및 로컬 컴퓨터의 터미널. –

+0

그것은 저를 위해 작동하고, 나는 무언가를 말하고 약간 초 후에 출력을 인쇄했다. 나는 당신이 당신의 마이크를 음소거했다는 것을 믿는다. 그리고 내가 가지고있는 ALSA 경고는 음량 레벨을 바꾸려고했지만 실패했다. 우분투 사운드 설정과 앨자 믹서를 모두 확인해야합니다. –

답변

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를 설치했다. –

관련 문제