OSError: No Default Input Device Available

Hi, I’m trying to build a web app that records sounds from users - but when I’m trying to access the default input device it is giving me errors like this -

ALSA lib confmisc.c:767:(parse_card) cannot find card '0'

ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory

ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings

ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory

ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name

ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory

ALSA lib conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory

ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM sysdefault

ALSA lib confmisc.c:767:(parse_card) cannot find card '0'

ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory

ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings

ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory

ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name

ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory

ALSA lib conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory

ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM sysdefault

ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.front

ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear

ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe

ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side

ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21

ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21

ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround40

ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround41

ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround50

ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround51

ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround71

ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958

ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958

ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958

ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi

ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi

ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem

ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem

ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline

ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline

ALSA lib confmisc.c:767:(parse_card) cannot find card '0'

ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory

ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings

ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory

ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name

ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory

ALSA lib conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory

ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM default

ALSA lib confmisc.c:767:(parse_card) cannot find card '0'

ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory

ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings

ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory

ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name

ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory

ALSA lib conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory

ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM default

ALSA lib confmisc.c:767:(parse_card) cannot find card '0'

ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory

ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings

ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory

ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name

ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory

ALSA lib conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory

ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM dmix

2022-10-23 06:17:19.912 Uncaught app exception

Traceback (most recent call last):

  File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 562, in _run_script

    exec(code, module.__dict__)

  File "/app/coughvid/app.py", line 95, in <module>

    frames = helper.record(duration, fs)

  File "/app/coughvid/helper/helper.py", line 101, in record

    input_device_index=audio.get_default_input_device_info()['index']

  File "/home/appuser/venv/lib/python3.9/site-packages/pyaudio.py", line 949, in get_default_input_device_info

    device_index = pa.get_default_input_device()

OSError: No Default Input Device Available

also FYI this is my github repo - https://github.com/ksraj/CoughVid you can find the requirement.txt and packages.txt from there and please let me know if anything needs any change.

Thanks

pyaudio is trying to access the input device in the server, not the client.

Hi, is there any solution for that? I want to access the client’s mic.

Usually you would use a component for that, access the mic with javascript in the client side and pass the data to the application by using the components API.

There is a Streamlit app that does speech-to-text using the streamlit-webrtc component. Maybe you can use the same component for your use case.

Find more in the component’s github page

1 Like

Thanks, I can able to access the client mic but while saving the file getting the below error

2022-10-23 21:06:16.172 Connection(0) Check CandidatePair(('10.12.14.214', 59765) -> ('192.168.0.101', 52600)) State.FROZEN -> State.WAITING

2022-10-23 21:06:16.172 ICE connection state is checking

2022-10-23 21:06:16.172 Connection(0) Check CandidatePair(('10.12.14.214', 59765) -> ('192.168.0.101', 52600)) State.WAITING -> State.IN_PROGRESS

2022-10-23 21:06:20.560 ICE connection state is closed

2022-10-23 21:06:23.943 Exception in callback Transaction.__retry()

handle: <TimerHandle when=1485708.125318041 Transaction.__retry()>

Traceback (most recent call last):

  File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 1054, in sendto

    self._sock.sendto(data, addr)

AttributeError: 'NoneType' object has no attribute 'sendto'


During handling of the above exception, another exception occurred:


Traceback (most recent call last):

  File "/usr/local/lib/python3.9/asyncio/events.py", line 80, in _run

    self._context.run(self._callback, *self._args)

  File "/home/appuser/venv/lib/python3.9/site-packages/aioice/stun.py", line 309, in __retry

    self.__protocol.send_stun(self.__request, self.__addr)

  File "/home/appuser/venv/lib/python3.9/site-packages/aioice/ice.py", line 243, in send_stun

    self.transport.sendto(bytes(message), addr)

  File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 1064, in sendto

    self._fatal_error(

  File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 711, in _fatal_error

    self._loop.call_exception_handler({

AttributeError: 'NoneType' object has no attribute 'call_exception_handler'

2022-10-23 21:06:46.754 Track audio received

2022-10-23 21:06:46.754 Add a track <aiortc.rtcrtpreceiver.RemoteStreamTrack object at 0x7f07ac31ca00> to receiver <streamlit_webrtc.receive.MediaReceiver object at 0x7f07ac0b3c70>

2022-10-23 21:06:46.754 Track audio is added to in_recorder

2022-10-23 21:06:46.775 Connection(1) Check CandidatePair(('10.12.14.214', 60625) -> ('192.168.0.101', 62500)) State.FROZEN -> State.WAITING

2022-10-23 21:06:46.775 ICE connection state is checking

2022-10-23 21:06:46.775 Connection(1) Check CandidatePair(('10.12.14.214', 60625) -> ('192.168.0.101', 62500)) State.WAITING -> State.IN_PROGRESS

2022-10-23 21:06:52.842 ICE connection state is closed

2022-10-23 21:06:54.432 Exception in callback Transaction.__retry()

handle: <TimerHandle when=1485738.614141957 Transaction.__retry()>

Traceback (most recent call last):

  File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 1054, in sendto

    self._sock.sendto(data, addr)

AttributeError: 'NoneType' object has no attribute 'sendto'


During handling of the above exception, another exception occurred:


Traceback (most recent call last):

  File "/usr/local/lib/python3.9/asyncio/events.py", line 80, in _run

    self._context.run(self._callback, *self._args)

  File "/home/appuser/venv/lib/python3.9/site-packages/aioice/stun.py", line 309, in __retry

    self.__protocol.send_stun(self.__request, self.__addr)

  File "/home/appuser/venv/lib/python3.9/site-packages/aioice/ice.py", line 243, in send_stun

    self.transport.sendto(bytes(message), addr)

  File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 1064, in sendto

    self._fatal_error(

  File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 711, in _fatal_error

    self._loop.call_exception_handler({

AttributeError: 'NoneType' object has no attribute 'call_exception_handler'

can you please have a look?

I’m afraid I can’t help you with that, not even if I knew what code you are running.

If you think it might be a problem with the component you can create an issue in its github.

1 Like

Figured out the error - issue seems to be because of this - https://github.com/aiortc/aiortc/issues/85

Hi Ksraj when i deploy my web app in the azure cloud even I’m currently facing the same issue while accessing the mic and I get

====================
OSError: No Default Input Device Available

Traceback:

File "/usr/local/lib/python3.8/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 552, in _run_script
    exec(code, module.__dict__)File "/app/app.py", line 68, in <module>
    run_streamlit_app()File "/app/app.py", line 43, in run_streamlit_app
    predicted_class, predicted_probabilities, class_names, results = prediction_nlp.audio_recording_prediction()File "/app/src/predict_pipeline.py", line 28, in audio_recording_prediction
    with sr.Microphone() as source:File "/usr/local/lib/python3.8/site-packages/speech_recognition/__init__.py", line 87, in __init__
    device_info = audio.get_device_info_by_index(device_index) if device_index is not None else audio.get_default_input_device_info()File "/usr/local/lib/python3.8/site-packages/pyaudio/__init__.py", line 812, in get_default_input_device_info
    device_index = pa.get_default_input_device()

===========================

It would be so kind if you assist me here

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.