在 Python 中使用语音识别在终端中获取不需要的输出

维雷吉·达萨尼

我使用名为“speech_recognition”的库编写了这段代码,其中它使用麦克风来获取用户所说的内容并将其打印到终端中。
这是代码:

import speech_recognition as sr
import webbrowser as wb

r1 = sr.Recognizer()
r2 = sr.Recognizer()

with sr.Microphone() as source:
    print('Give command')
    audio = r1.listen(source)
    command = r2.recognize_google(audio)
    print (command)

我希望这首先print('Give command')是它听音频并打印出它听到的内容。
它确实这样做了,但这是我说“你好,请帮忙”时得到的整个输出:

ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_route.c:869:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:869:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:869:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:869:(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
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
ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port
ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port
ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card
ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card
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
Give command
hello please help

输出的最后两行是我唯一想看到的。

超级机器人

如果您使用的是语音识别。像语音助手这样的库,最好不要使用终端来显示 o/p。相反,在语音中输出。这使应用程序更好,并摆脱了所有这些垃圾警告

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

我无法在 Python 中使用语音识别来查看我的文本输出

使用语音识别在 Python 中将音频 Blob 转换为文本

Python神经网络中不需要的[Nan]输出

在 python 中使用 pandas 不需要的空数据框

从请求中获取不需要的响应 Python

使用Python的Flask和jsonpickle在JSON中获取不需要的转义字符

使用不需要互联网的Python实现逼真的文本到语音转换?

如何使用python从列表中删除不需要的元素

使用BeautifulSoup在Python中删除不需要的标签

使用python在csv中删除不需要的行

使用Python从图像中删除不需要的连接像素

在python中打印不需要的符号

为什么在python中使用Apply Map函数替换标头名称中不需要的字符时出现错误

从网站上抓取的不需要的 CSV 输出|使用 Python 和 Selenium

在 python 中使用 pandas 不需要的空數據框

如何从python中的csv中删除不需要的行?

语音识别的输出(Python)

ansible 中不需要 python2.7 的任务示例?

Python在字典中添加不需要的双引号

删除python webscaping循环结果中不需要的元素

为什么yield函数在Python中不需要括号?

在python数据框中删除不需要的列

如何在python中删除不需要的字符

在python中打印不需要的字符的代码

刪除 python pandas 中不需要的字符

如何从python列表中删除/排除不需要的对象

为什么我们不需要导入任何模块来在python中使用print()、input()、len()、int()等函数

使用语音识别后的python无法删除音频文件

Python PyAudio中的语音识别需要Visual Studio错误