Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[audio_listener-1] ALSA lib error #16

Open
codingBigBird opened this issue Jul 9, 2024 · 8 comments
Open

[audio_listener-1] ALSA lib error #16

codingBigBird opened this issue Jul 9, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@codingBigBird
Copy link

codingBigBird commented Jul 9, 2024

After getting some updates, My whisper can't run and it gives some errors when running
ros2 launch whisper_bringup bringup.launch.py.
And there is no audio_listener node on ros2 node list and the server doesn't run.
how to solve this issue?

[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [audio_listener-1]: process started with pid [66674]
[INFO] [component_container_mt-2]: process started with pid [66676]
[audio_listener-1] ALSA lib confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.1.pcm.hdmi.0:CARD=1,AES0=4,AES1=130,AES2=0,AES3=2'
[audio_listener-1] ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
[audio_listener-1] ALSA lib conf.c:5701:(snd_config_expand) Evaluate error: No such file or directory
[audio_listener-1] ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM hdmi
[audio_listener-1] ALSA lib confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.1.pcm.hdmi.0:CARD=1,AES0=4,AES1=130,AES2=0,AES3=2'
[audio_listener-1] ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
[audio_listener-1] ALSA lib conf.c:5701:(snd_config_expand) Evaluate error: No such file or directory
[audio_listener-1] ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM hdmi
[audio_listener-1] ALSA lib confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.1.pcm.modem.0:CARD=1'
[audio_listener-1] ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
[audio_listener-1] ALSA lib conf.c:5701:(snd_config_expand) Evaluate error: No such file or directory
[audio_listener-1] ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline:CARD=1,DEV=0
[audio_listener-1] ALSA lib confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.1.pcm.modem.0:CARD=1'
[audio_listener-1] ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
[audio_listener-1] ALSA lib conf.c:5701:(snd_config_expand) Evaluate error: No such file or directory
[audio_listener-1] ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline:CARD=1,DEV=0
[audio_listener-1] ALSA lib confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.1.pcm.modem.0:CARD=1'
[audio_listener-1] ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
[audio_listener-1] ALSA lib conf.c:5701:(snd_config_expand) Evaluate error: No such file or directory
[audio_listener-1] ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM phoneline
[audio_listener-1] ALSA lib confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.1.pcm.modem.0:CARD=1'
[audio_listener-1] ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
[audio_listener-1] ALSA lib conf.c:5701:(snd_config_expand) Evaluate error: No such file or directory
[audio_listener-1] ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM phoneline
[audio_listener-1] ALSA lib pcm_oss.c:397:(_snd_pcm_oss_open) Cannot open device /dev/dsp
[audio_listener-1] ALSA lib pcm_oss.c:397:(_snd_pcm_oss_open) Cannot open device /dev/dsp
[audio_listener-1] ALSA lib confmisc.c:160:(snd_config_get_card) Invalid field card
[audio_listener-1] ALSA lib pcm_usb_stream.c:482:(_snd_pcm_usb_stream_open) Invalid card 'card'
[audio_listener-1] ALSA lib confmisc.c:160:(snd_config_get_card) Invalid field card
[audio_listener-1] ALSA lib pcm_usb_stream.c:482:(_snd_pcm_usb_stream_open) Invalid card 'card'

jackd

@mhubii
Copy link
Collaborator

mhubii commented Jul 9, 2024

Seems like you are having trouble running the audio driver

@codingBigBird
Copy link
Author

codingBigBird commented Jul 9, 2024

Hi mhubii, thanks for reaching with me.
Yes I know this is the problem of audio driver, but there is a few solution on the internet. I tried 'https://stackoverflow.com/questions/7088672/pyaudio-working-but-spits-out-error-messages-each-time' but it did not work. Anything else I can do to fix the it?

@mhubii
Copy link
Collaborator

mhubii commented Jul 10, 2024

so essentially I have no experience with that sorry. But you need to be able and run this node for grabbing audio (also launched as part of the bringup package):

ros2 run audio_listener audio_listener

@codingBigBird
Copy link
Author

codingBigBird commented Jul 10, 2024

Hi I solve the ALSA lib problem. https://stackoverflow.com/questions/65079325/problem-with-alsa-in-speech-recognitionpython-3
But the server doesn't run in ros. Sorry about these questions I don't know so much about ROS2.
image
Screenshot from 2024-07-10 16-07-14

@mhubii
Copy link
Collaborator

mhubii commented Jul 11, 2024

No worries, maybe try pull the latest changes.

You can list nodes in terminal with ros2 node list.

You can run rqt_graph to observe the ROS 2 graph.

@TheHassanShahzad
Copy link

TheHassanShahzad commented Nov 25, 2024

Hi i had the same problem but I managed to find a fix

Initially i ran `ros2 run audio_listener audio_listener` but got these errors:
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_route.c:877:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:877:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:877:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:877:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_oss.c:397:(_snd_pcm_oss_open) Cannot open device /dev/dsp
ALSA lib pcm_oss.c:397:(_snd_pcm_oss_open) Cannot open device /dev/dsp
ALSA lib confmisc.c:160:(snd_config_get_card) Invalid field card
ALSA lib pcm_usb_stream.c:482:(_snd_pcm_usb_stream_open) Invalid card 'card'
ALSA lib confmisc.c:160:(snd_config_get_card) Invalid field card
ALSA lib pcm_usb_stream.c:482:(_snd_pcm_usb_stream_open) Invalid card 'card'
^CTraceback (most recent call last):
  File "/home/hassan/ros2_ws/install/audio_listener/lib/audio_listener/audio_listener", line 33, in <module>
    sys.exit(load_entry_point('audio-listener==1.3.1', 'console_scripts', 'audio_listener')())
  File "/home/hassan/ros2_ws/install/audio_listener/lib/python3.10/site-packages/audio_listener/audio_listener.py", line 71, in main
    rclpy.spin(audio_listener)
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/__init__.py", line 222, in spin
    executor.spin_once()
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 739, in spin_once
    self._spin_once_impl(timeout_sec)
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 734, in _spin_once_impl
    handler()
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/task.py", line 239, in __call__
    self._handler.send(None)
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 437, in handler
    await call_coroutine(entity, arg)
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 351, in _execute_timer
    await await_or_execute(tmr.callback)
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 107, in await_or_execute
    return callback(*args)
  File "/home/hassan/ros2_ws/install/audio_listener/lib/python3.10/site-packages/audio_listener/audio_listener.py", line 53, in audio_publisher_timer_callback_
    audio = self.stream_.read(self.frames_per_buffer_)
  File "/home/hassan/.local/lib/python3.10/site-packages/pyaudio/__init__.py", line 570, in read
    return pa.read_stream(self._stream, num_frames,
KeyboardInterrupt
[ros2run]: Interrupt

The main problem was pyaudio was not finding a valid microphone input

I ran:
arecord -l

to ensure a mic device was even available on my system

then ran this in a seperate file to get the necessary data from my mic:

p = pyaudio.PyAudio()
for i in range(p.get_device_count()):
    print(p.get_device_info_by_index(i))

from this i got the sample rate which i modified in

        self.declare_parameters(
            namespace="",
            parameters=[
                ("channels", 1),
                ("frames_per_buffer", 1000),
                ("rate", 44100),
            ],
        )

and replaced the bit of code beneath that with this:

        self.stream_ = self.pyaudio_.open(
            channels=self.channels_,
            format=pyaudio.paInt16,
            input=True,
            frames_per_buffer=self.frames_per_buffer_,
            rate=self.rate_,
            input_device_index=0  # Using device index 0 for ALC298 Analog
        )

Now when i run the node, i get these errors:

ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_route.c:877:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:877:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:877:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:877:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_oss.c:397:(_snd_pcm_oss_open) Cannot open device /dev/dsp
ALSA lib pcm_oss.c:397:(_snd_pcm_oss_open) Cannot open device /dev/dsp
ALSA lib confmisc.c:160:(snd_config_get_card) Invalid field card
ALSA lib pcm_usb_stream.c:482:(_snd_pcm_usb_stream_open) Invalid card 'card'
ALSA lib confmisc.c:160:(snd_config_get_card) Invalid field card
ALSA lib pcm_usb_stream.c:482:(_snd_pcm_usb_stream_open) Invalid card 'card'

but the code manages to publishes to the topic anyway so i guess it works

i can suppress the warnings by running:

ros2 run audio_listener audio_listener 2>/dev/null

@mhubii mhubii added the bug Something isn't working label Nov 28, 2024
@mhubii
Copy link
Collaborator

mhubii commented Dec 12, 2024

thanks again for providing the solution @TheHassanShahzad! Do you think this is something that can be solved generally?

@TheHassanShahzad
Copy link

i think so. Provided you have a script which can parse out the relevant information fit the microphone and automatically update the parameters in the node, it should be a general solution

a problem you may encounter is devices with multiple microphones but i'm not sure how you'd deal with that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants