Error "Invalid value for card" with mic in my Node script - node.js

I'm trying to build a little Node script to listen to the microphone and then send the audio to a server and I'm stuck with the mic package.
I get this error:
Received Info: ALSA lib pcm_hw.c:1713:(_snd_pcm_hw_open) Invalid value for card
arecord: main:788:
Received Info: erreur à l'ouverture audio: Aucun fichier ou dossier de ce type
I have tried to run arecord -d 5 -f U8 sample.mp3 on my machine (Linux) and it works well (I can then listen to what I said with aplay sample.mp3).
I have seen a similar post but don't really understand how this applies to my case. In case you need, this is the output of arecord -l
**** Liste des Périphériques Matériels CAPTURE ****
carte 0: PCH [HDA Intel PCH], périphérique 0: ALC269VC Analog [ALC269VC Analog]
Sous-périphériques: 0/1
Sous-périphérique #0: subdevice #0
And this is the options object I pass to mic
"MIC_CONFIG": {
"rate": 8000,
"channels": 1,
"debug": true,
"exitOnSilence": 6
}
Thanks for helping

Related

pygame No available audio device

I code on Ubuntu 20.04LTS with python 3.8.2 and in my game, I want to put music, so I use this:
pygame.mixer.init()
music = pygame.mixer.Sound(os.path.join(current_path,'something.mp3'))
music.play()
But I receive this error:
pygame.mixer.init()
pygame.error: No available audio device
What I have to do?
A common problem is selecting the right sound device, if more than one i present.
to list devices:
cat /proc/asound/cards
It could look like this:
0 [CUBE ]: USB-Audio - Audiotrak ProDigy CUBE GYROCOM C&C Co., LTD Audiotrak ProDigy CUBE at usb-0000:04:00.0-2, full speed
1 [IM ]: USB-Audio - VF0530 Live! Cam Chat IM Creative Labs VF0530 Live! Cam Chat IM at usb-0000:04:00.0-1, high speed
2 [HDMI ]: HDA-Intel - HDA ATI HDMI HDA ATI HDMI at 0xf7e60000 irq 45
Then you must edit the ~/.asoundrc to use the right device.
If you want to use device 0, set that value for pcm card:
pcm.!default {
type hw
card 0
}
ctl.!default {
type hw
card 0
}
Also make sure the following libs are installed and configured:
sudo apt-get install libsdl1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev
sudo sdl-config --cflags --libs

Nixos default audio device

I'm trying to configure the default audio device on a NixOS host.
My alsa devices are thus:
$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: NVidia [HDA NVidia], device 3: HDMI 0 [HDMI 0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: NVidia [HDA NVidia], device 7: HDMI 1 [HDMI 1]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: Generic [HD-Audio Generic], device 0: ALC1220 Analog [ALC1220 Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: Generic [HD-Audio Generic], device 1: ALC1220 Digital [ALC1220 Digital]
Subdevices: 1/1
Subdevice #0: subdevice #0
I don't have HDMI or digitaul audio devices; I just want to use the regular ALC1220 Analog device.
I currently have AUDIODEV=hw:1,0 set in my environment (for sox), and alsa-audio-device=sysdefault:CARD=Generic in my vlcrc. That works, but it is obviously user- and app- specific, and is a pain for declaritiveness (declarity?).
It seems that it should be something I can set at the host level, e.g., by setting
sound.extraConfig =
''
pcm.!default {
type hw
card Generic
}
'';
in my configuration.nix, or possibly configuring pulseaudio.
I have sought help in the NixOS Wiki (ALSA, Pulse), on other sites such as ArchLinux, Pulse documentation, and other sites like StackOverflow (e.g., stackexchange), but I can find nothing that actually works.
I have tried the above, and variants thereof; and also tried with & without Pulse; but I have found nothing that works.
Simply being able to sound audio to all the devices on that card would be jolly good, too.
As always, any pointers gratefully recieved.
Update: here is my /etc/asound.conf
pcm_type.pulse {
libs.native = /nix/store/a3v4gh5lbb2g8fizq9xh8nbdp8qrvs6r-alsa-plugins-1.1.6/lib/alsa-lib/libasound_module_pcm_pulse.so ;
}
pcm.!default {
type pulse
hint.description "Default Audio Device (via PulseAudio)"
}
ctl_type.pulse {
libs.native = /nix/store/a3v4gh5lbb2g8fizq9xh8nbdp8qrvs6r-alsa-plugins-1.1.6/lib/alsa-lib/libasound_module_ctl_pulse.so ;
}
ctl.!default {
type pulse
}
(and that module is real):
$ ls -l /nix/store/a3v4gh5lbb2g8fizq9xh8nbdp8qrvs6r-alsa-plugins-1.1.6/lib/alsa-lib/libasound_module_ctl_pulse.so
-r-xr-xr-x 1 root root 33512 Jan 1 1970 /nix/store/a3v4gh5lbb2g8fizq9xh8nbdp8qrvs6r-alsa-plugins-1.1.6/lib/alsa-lib/libasound_module_ctl_pulse.so
This problem is most likely due to pulseaudio comandeering the default device, despite listing it in ~/.asoundrc.
The best solution to override pulse's comandeering of the default device with an alsa hook. To do this, edit your ~/.asoundrc with the following contents at the top :
#hooks [
{
func load
files [
"~/.asoundrc"
]
errors false
}
]
You can then add you default device as required, probably something like the following in your case :
pcm.!default {
type hw
card "Generic"
}
ctl.!default {
type hw
card "Generic"
}

How to fix: device_list:270: no soundcard found (Ubuntu server 18.04)?

I was trying to capture some audio using a usb microphone and I got the error message mentioned in the title.
here is the output some (hopefully relevant) commands:
arecord -l
arecord: device_list:270: no soundcards found...
ls /cat/asound*
ls: cannot access '/cat/asound*': No such file or directory
lspci -v
00:1b.0 Audio device: Intel Corporation 7 Series/C216 Chipset Family High Definition Audio Controller (rev 04)
Subsystem: Hewlett-Packard Company 7 Series/C216 Chipset Family High Definition Audio Controller
Flags: bus master, fast devsel, latency 0, IRQ 29
Memory at f7c30000 (64-bit, non-prefetchable) [size=16K]
Capabilities: <access denied>
Kernel driver in use: snd_hda_intel
Kernel modules: snd_hda_intel
I've tried to remove and install alsa again and when I run
sudo arecord -l
The output is:
**** List of CAPTURE Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC221 Analog [ALC221 Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 2: ALC221 Alt Analog [ALC221 Alt Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
I guess meaning Ubuntu is recognising my sound card. The ALSA Info script can be found here.
Any help would be greatly appreciated.
I had aplay: device_list:268: No sound card found... after using aplay l. Following the Ubuntu troubleshooting guide below, I installed apt install linux-generic and after reboot it found my soundcard from VirtualBox in Ubuntu Server 20.04 from ova.
https://help.ubuntu.com/community/SoundTroubleshooting

Raspberry Pi - uv4l WebRTC no audio

I've setup up my Raspberry Pi 2 running Wheezy to stream video via uv4l / uv4l-server. I have both a Pi Camera and a USB Microsoft LifeCam HD-5000. I launched uv4l with each driver for each camera and the streaming works fine except for the audio. I'm trying to use my USB webcam as the microphone to stream audio. I read on the uv4l documentation that it picks up the first audio device from "arecord -l" has the audio input and mine prints:
**** List of CAPTURE Hardware Devices ****
card 0: HD5000 [Microsoft LifeCam HD-5000], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
I changed my /etc/modprobe.d/alsa-base.conf to match the one on this page: http://www.linux-projects.org/modules/sections/index.php?op=viewarticle&artid=14
I can record audio and play it back by doing:
arecord -D plughw:0,0 -d5 test.wav
aplay -D plughw:1,0 test.wav
Can someone please point me what I'm missing to be able to stream video and audio via uv4l?
Thank you!
Have you tried with or without PulseAudio? Try to uninstall it first.

Errors using pyAudio

I'm trying to use the pyaudio examples provided on https://people.csail.mit.edu/hubert/pyaudio/#examples.
I have two Raspberry Pis, both of them have the pyAudio installed. One of them can run the examples wihtout any issues, however the other one spits the following error messages when trying to record audio for example:
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused
ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused
ALSA lib pcm_dmix.c:957:(snd_pcm_dmix_open) The dmix plugin supports only playback stream
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
Expression 'parameters->channelCount <= maxChans' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1438
Expression 'ValidateParameters( inputParameters, hostApi, StreamDirection_In )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2742
Traceback (most recent call last):
File "audioRecord.py", line 17, in <module>
frames_per_buffer=CHUNK)
File "/usr/local/lib/python3.2/dist-packages/pyaudio.py", line 747, in open
stream = Stream(self, *args, **kwargs)
File "/usr/local/lib/python3.2/dist-packages/pyaudio.py", line 442, in __init__
self._stream = pa.open(**arguments)
IOError: [Errno Invalid number of channels] -9998
I have the following audio configs:
$ cat /proc/asound/modules
0 snd_usb_audio
1 snd_bcm2835
$ lsusb
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 0bda:8178 Realtek Semiconductor Corp. RTL8192CU 802.11n WLAN Adapter
Bus 001 Device 005: ID 046d:c31c Logitech, Inc. Keyboard K120 for Business
Bus 001 Device 006: ID 046d:c077 Logitech, Inc.
Bus 001 Device 007: ID 0d8c:000c C-Media Electronics, Inc. Audio Adapter
$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Set [C-Media USB Headphone Set], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
Subdevices: 8/8
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
Subdevice #7: subdevice #7
card 1: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]
Subdevices: 1/1
Subdevice #0: subdevice #0
Could you please advise, what can be missing on this second device?
The solution was to make the sound device 0 as default.

Resources