Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/362.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
语音“U识别模块卡在”中;说点什么python_Python_Python 2.7_Speech Recognition - Fatal编程技术网

语音“U识别模块卡在”中;说点什么python

语音“U识别模块卡在”中;说点什么python,python,python-2.7,speech-recognition,Python,Python 2.7,Speech Recognition,我正在尝试一个用于语音识别的python脚本,我已经在我的环境中安装了所需的pyaudio和SpeechRecognition模块 直到昨天,这个程序还运行得很好,但现在它陷入了“说点什么”的状态。下面是我的代码 import speech_recognition as sr print "say something1" r = sr.Recognizer() print "say something2" with sr.Microphone() as source:

我正在尝试一个用于语音识别的python脚本,我已经在我的环境中安装了所需的pyaudio和SpeechRecognition模块

直到昨天,这个程序还运行得很好,但现在它陷入了“说点什么”的状态。下面是我的代码

import speech_recognition as sr
print "say something1"
r = sr.Recognizer()
print "say something2"
with sr.Microphone() as source:                # use the default microphone as the audio source
    print "say something3"
    audio = r.listen(source,timeout=3)                   # listen for the first phrase and extract it into audio data

print "say something"
try:
    print("You said " + r.recognize(audio))    # recognize speech using Google Speech Recognition
except LookupError:                            # speech is unintelligible
    print("Could not understand audio")
控制台o/p:-

say something1
say something2
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.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_dmix.c:1029:(snd_pcm_dmix_open) unable to open slave
say something3

不是重复的/已引用到:-

我也有同样的问题,我最终安装了jack2d和pulseaudio等等

这就是问题所在,然后我通过运行

sudo apt-get remove --auto-remove jack
然后重新启动系统,然后运行

jack_control  stop
然后,这将为pulse aduio提供语音输入

运行程序时,控制台应打印

ALSA lib pcm_dsnoop.c:606:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
最后一行表示Jack已停止,语音输入被重定向到pulse

这里实际发生的事情是,音频分辨率(麦克风)只传送到插孔或脉冲,所以我卸载了插孔


现在,当我按原样尝试您的代码时,我的程序运行得很好,出现了以下
属性
错误

AttributeError: 'Recognizer' object has no attribute 'recognize'
经过检查后,它看起来像是
识别器
类没有方法
识别
。您需要使用
recognize
类提供的几种
recognize
方法之一。
似乎你想使用
recognize\u google
,所以当我从

print("You said " + r.recognize(audio))

代码对我有用

我说了声“你好”,这在下面被认出来了

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 something1
say something2
say something3
say something
You said hello

希望这能帮上忙。

也许这能解决你的问题

print "say something2"
with sr.Microphone() as source:                # use the default microphone as the audio source
    r.adjust_for_ambient_noise(source)  # here
    print "say something3"
    audio = r.listen(source,timeout=3)   
看看这个。


最后一个解决方案对我有效。希望你也能做同样的工作

我也遇到了这个问题,正在改变

audio = r.listen(source,timeout=3)


为我解决了这个问题。

我也面临着同样的问题。在问了同样的问题之后,我看到了这个问题,这个问题也没有得到回答:(.你还困在里面吗?说点什么?是的。我从过去10个小时就开始工作了,但没有结果。如果你能帮助我,我将不胜感激。当然。告诉我你是否有pulse audio,jack2d n其他音频程序,如果有。将它们列出给我,让我安装pulse audio和jack2d。然后删除jack2d
audio = r.listen(source,timeout=3)
audio = r.listen(source,timeout=3, phrase_time_limit=3)