I'm setting up a sound recognizer with the speechRecognition python library.
This is my code so far:
#!/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))
On running I get
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
I'm using SpeechRecognition version 1.3.1 running on Linux LXLE 14.04 x64 with python 3.4
It tells you it can not record audio on your device. It is not related to a jack server, it also tries to open alsa device and bluetooth audio device. Make sure that audio is properly set on your device. See also
PyAudio does not work and bricks sound on ubuntu
PyAudio working, but spits out error messages each time
I am having this same error. If you would like a work around you can use my code I wrote. I used the sounddevice library to record audio while there is audio it saves into one file, then convert it to text using the speech recognition library. The error comes when microphone is called in as it is using PyAudio.
https://shepai.github.io/code/PetSHEP/soundLib.py
The following lines should replace your "with microphone" bit
with sr.AudioFile(filename) as source:
Audio=r.record(source)
This is how I got round the problem, hope it helps :)
Related
When i run below python script it shows some error.
import speech_recognition as s
sr=s.Recognizer()
print("Please, speak now....")
with s.Microphone() as m:
audio=sr.listen(m)
query=sr.recognize_google(audio,language='eng-in')
print(query)
I tried almost all solution available online but still my problem is not solved.
The error massage in command line is:
ALSA lib pcm_dmix.c:1089:(snd_pcm_dmix_open) unable to open slave
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
connect(2) call to /dev/shm/jack-1000/default/jack_0 failed (err=No such file or directory)
attempt to connect to server failed
connect(2) call to /dev/shm/jack-1000/default/jack_0 failed (err=No such file or directory)
attempt to connect to server failed
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
ALSA lib pcm_dmix.c:1089:(snd_pcm_dmix_open) unable to open slave
connect(2) call to /dev/shm/jack-1000/default/jack_0 failed (err=No such file or directory)
attempt to connect to server failed
But when i run this python script on jupyter-notebook or Pycharm it does't show any error but still not taking any input from microphone(but microphone start) and also not showing any output.
I started making a virtual assistant program taking help from this YouTube video(https://www.youtube.com/watch?v=AGatX_8gaeM).
I made the basic speech recognition code but it isn't responding to voice inputs to both internal microphone and external microphone.
When I run the program
import speech_recognition as sr
from gtts import gTTS
def recordAudio():
record=sr.Recognizer()
with sr.Microphone() as source:
print('Say something!')
audio=record.listen(source)
data=''
try:
data=record.recognize_google(audio)
print('You said: {}'.format(data))
except sr.UnknownValueError:
print('Ran into some unknown error retry....')
recordAudio()
except sr.RequestError:
print('Ran into request error retry....')
recordAudio()
except:
print('Ran into something other than UnknownValueError or RequestError')
recordAudio()
but this happens:
ALSA lib pcm_dsnoop.c:641:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib pcm_dmix.c:1089:(snd_pcm_dmix_open) unable to open slave
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_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_a52.c:823:(_snd_pcm_a52_open) a52 is only for playback
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
ALSA lib pcm_dmix.c:1089:(snd_pcm_dmix_open) unable to open slave
Say something!
And the command
import speech_recognitioin as sr
sr.Microphone.list_microphone_names()
returns this:
ALSA lib pcm_dsnoop.c:641:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib pcm_dmix.c:1089:(snd_pcm_dmix_open) unable to open slave
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_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_a52.c:823:(_snd_pcm_a52_open) a52 is only for playback
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
ALSA lib pcm_dmix.c:1089:(snd_pcm_dmix_open) unable to open slave
['HD-Audio Generic: HDMI 0 (hw:0,3)', 'HD-Audio Generic: ALC236 Analog (hw:1,0)', 'hdmi',
'pulse', 'default']
Can somebody help me out with this.
You have to connect a microphone on your laptop or pc
Because for giving inputs through voice need microphone
Firts:
you need a microphone
Second
Check if EVERY bracket has a closing part and if it still doesn't work then start over from scratch
Hi i'm trying to build a nodejs app on my raspberry pi model 4 that after receiving an input (nfc tag)
open a url that contain a video.
Es 'http://www.example.com/webapi/content?rfid=05:66:77:66:93:67'.
The problem is that when i try to open my link with vlc or omxplayer it drop an error and doesn't show me any video. I try to put the link in the "open network stream" on vlc in windows and i have the same issue, but if i put the link in the browser I see the video correctly. If i try to open other videos i didn't get any problem.
Unfortunately I can't post the link to the site for privacy reasons. Any advice on what the problem might be?
Error log on raspberry pi:
[01cf9b80] vlcpulse audio output error: PulseAudio server connection failure: Connection refused
[01d089f0] dbus interface error: Failed to connect to the D-Bus session daemon: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
[01d089f0] main interface error: no suitable interface module
[01c72b58] main libvlc error: interface "dbus,none" initialization failed
[01d152c0] main interface error: no suitable interface module
[01c72b58] main libvlc error: interface "globalhotkeys,none" initialization failed
[01c72b58] main libvlc: Esecuzione di vlc con l'interfaccia predefinita. Usa 'cvlc' per utilizzare vlc senza interfaccia.
error: XDG_RUNTIME_DIR not set in the environment.
[01d152c0] skins2 interface error: cannot initialize OSFactory
[01d152c0] [cli] lua interface: Listening on host "*console".
VLC media player 3.0.8 Vetinari
Command Line Interface initialized. Type `help' for help.
> [b1002098] mp4 stream error: no moov before mdat and the stream is not seekable
[b1001e58] prefetch stream error: cannot seek (to offset 48)
[b1054990] mmal_codec decoder: VCSM init succeeded: CMA
[mov,mp4,m4a,3gp,3g2,mj2 # 0xb104e340] stream 0, offset 0x4d3: partial file
I am trying SpeechRecognition module but i can get it to work.
Can anyone pleas help me.
I am using Linux Mint
Thias is my python code:
import speech_recognition as sr
r = sr.Recognizer()
try:
with sr.Microphone() as source:
audio = r.listen(source)
text = r.recognize_google(audio)
print(text)
except:
print("not working")
and I get this error:
ALSA lib pcm_dsnoop.c:618:(snd_pcm_dsnoop_open) unable to open
slave
ALSA lib pcm_dmix.c:1052:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM
cards.pcm.rear
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM
cards.pcm.center_lfe
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM
cards.pcm.side
ALSA lib pcm_dmix.c:1052:(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
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1,
skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1,
skipping unlock
Expression 'parameters->channelCount <= maxChans' failed in
'src/hostapi/alsa/pa_linux_alsa.c', line: 1514
Expression 'ValidateParameters( inputParameters, hostApi,
StreamDirection_In )' failed in
'src/hostapi/alsa/pa_linux_alsa.c',
line: 2818
not working
I would like to play sound in octave with pulseaudio. I saw this post but the octave audio management is changed in the new releases and it is not longer possible to use paplay like say that post, I have the version 4.2.1-4
Now when I try to use sound or audiolayer functions I get these errors:
ALSA lib pcm_dmix.c:1052:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2495:(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_dmix.c:1052:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm_dmix.c:1052:(snd_pcm_dmix_open) unable to open slave
connect(2) call to /dev/shm/jack-1000/default/jack_0 failed (err=No such file or directory)
attempt to connect to server failed
And no sound is played, next, if I retry to use sound I don't get error and it waits for the sound duration, however it keep to not play sound.
It seems it would like to use ALSA, but I'm using pulseaudio what can i do?
EDIT:
I notice that sometimes the error message change and it say:
ALSA lib pcm_dmix.c:1052:(snd_pcm_dmix_open) unable to open slave
Expression 'ret' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1735
Expression 'AlsaOpen( &alsaApi->baseHostApiRep, params, streamDir, &self->pcm )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1902
Expression 'PaAlsaStreamComponent_Initialize( &self->playback, alsaApi, outParams, StreamDirection_Out, NULL != callback )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2170
Expression 'PaAlsaStream_Initialize( stream, alsaHostApi, inputParameters, outputParameters, sampleRate, framesPerBuffer, callback, streamFlags, userData )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2835
error: audioplayer: unable to open audio playback stream
error: called from
playblocking at line 36 column 3
sound at line 59 column 3