语音识别模块卡在“说点什么"中;- Python [英] speech_recognition module stuck in "say something" - python

查看:201
本文介绍了语音识别模块卡在“说点什么"中;- Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying a python script for speech recognition, i have installed the required pyaudio and SpeechRecognition modules in my enivronment.

直到昨天该程序运行良好,但现在卡在说点什么"中.下面是我的代码.

The program was running fine till yesterday, but now it is stuck in "say something". Below is my code.

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

不重复/有提到:- 语音识别python代码不起作用

推荐答案

也许这可以解决您的问题.

May be this can solve your problem.

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)   

看看这个.https://github.com/Uberi/speech_recognition/issues/191

最后一个解决方案对我有用.希望同样的工作为您服务

Last solution work for me . hope same work for your

这篇关于语音识别模块卡在“说点什么"中;- Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆