I am trying to use pyaudio and pyspeech to record an audio sample and interpret what is said. I then intend to use that to trigger a conversation with an agent but I am having trouble with ALSA not using the on-board microphone.
Python program:
#!/usr/bin/env python3
# Requires PyAudio and PySpeech
import speech_recognition as sr
# Record Audio
r=sr.Recognizer()
with sr.Microphone() as source:
print("Say something!")
audio = r.listen(source)
# Speech recognition using google speech recognition
try:
#this uses the generic API key which cannot query more than 50x per day
print("You said: " + r.recognize_google(audio))
except sr.UnknownValueError:
print("Google Speech Recognition could not understand audio")
except sr.RequestError as e:
print("Could not request results from Google Speech Recognition service; {0}".format(e))
When I run it, I get the errors:
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 something!
While is says "Say something!" it is not actually listening. I have tried the ALSA troubleshooting page: https://wiki.debian.org/ALSA#Troubleshooting
and get the following results:
$ cat /proc/asound/cards
produces:
0 [HDMI ]: HDA-Intel - HDA Intel HDMI
HDA Intel HDMI at 0xedc14000 irq 33
1 [PCH ]: HDA-Intel - HDA Intel PCH
HDA Intel PCH at 0xedc10000 irq 32
I can add myself as an audio user:
$sudo adduser jd audio
Adding user `jd' to group `audio' ...
Adding user jd to group audio
Done.
But when I go to edit the /etc/modprobe.d/sound it does not exist:
$ls /etc/modprobe.d/
alsa-base.conf blacklist-rare-network.conf
blacklist-ath_pci.conf blacklist-watchdog.conf
blacklist-bcm43.conf dkms.conf
blacklist.conf fbdev-blacklist.conf
blacklist-firewire.conf intel-microcode-blacklist.conf
blacklist-framebuffer.conf iwlwifi.conf
blacklist-modem.conf libopenni-sensor-pointclouds0.conf
blacklist-oss.conf mlx4.conf
What do I need to do to set the default microphone to the on-board microphone?
I have similar errors. This is how I fix is. For the first you need pulseaudio volume control program. Just run from terminal following command
sudo apt-get update && sudo apt-get install pavucontrol paman
Then run alsa audio_file_name.mp3
Then open pulseaudio from your gui. In Playback section you can find ALSA ,from the top right side you can chose default input/output device for ALSA and set your headphones for example
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.