speechRecognition:jack服务器没有运行

时间:2015-07-26 22:53:11

标签: linux speech-recognition python-3.4

我正在使用 speechRecognition python库设置声音识别器。

到目前为止,这是我的代码:

#!/usr/bin/env python3

import speech_recognition as sr

r = sr.Recognizer('es-MX')

with sr.Microphone() as mic:
    audio = r.listen(mic)

print(r.recognize(audio))

跑步时我得到了

ALSA lib pcm_dsnoop.c:618:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_l$
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
bt_audio_service_open: connect() failed: Connection refused (111)
bt_audio_service_open: connect() failed: Connection refused (111)
bt_audio_service_open: connect() failed: Connection refused (111)
bt_audio_service_open: connect() failed: Connection refused (111)
ALSA lib pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave
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

我使用在Linux LXLE 14.04 x64和python 3.4上运行的SpeechRecognition 1.3.1版

2 个答案:

答案 0 :(得分:2)

它告诉您它无法在您的设备上录制音频。它与插孔服务器无关,它还尝试打开alsa设备和蓝牙音频设备。确保在设备上正确设置了音频。另见

PyAudio does not work and bricks sound on ubuntu

PyAudio working, but spits out error messages each time

答案 1 :(得分:1)

我遇到了同样的错误。如果您想解决问题,可以使用我编写的代码。我使用声音设备库来记录音频,同时将音频保存到一个文件中,然后使用语音识别库将其转换为文本。使用PyAudio调用麦克风时出现错误。

https://shepai.github.io/code/PetSHEP/soundLib.py

以下几行应替换您的“带有麦克风”位

以sr.AudioFile(filename)作为源: 音频= r.record(源)

这就是我解决问题的方式,希望对您有所帮助:)