soundmeter icon indicating copy to clipboard operation
soundmeter copied to clipboard

python---IOError: No Default Input Device Available

Open vishallight opened this issue 6 years ago • 8 comments

~# python -m speech_recognition ALSA lib pcm_dsnoop.c:638:(snd_pcm_dsnoop_open) unable to open slave ALSA lib pcm_dmix.c:1099:(snd_pcm_dmix_open) unable to open slave ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe ALSA lib pcm.c:2565:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side ALSA lib pcm_dsnoop.c:638:(snd_pcm_dsnoop_open) unable to open slave ALSA lib pcm_dmix.c:1099:(snd_pcm_dmix_open) unable to open slave ALSA lib pcm_dmix.c:1099:(snd_pcm_dmix_open) unable to open slave Traceback (most recent call last): File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main "main", fname, loader, pkg_name) File "/usr/lib/python2.7/runpy.py", line 72, in _run_code exec code in run_globals File "/usr/local/lib/python2.7/dist-packages/speech_recognition/main.py", line 4, in m = sr.Microphone() File "/usr/local/lib/python2.7/dist-packages/speech_recognition/init.py", line 86, 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/python2.7/dist-packages/pyaudio.py", line 949, in get_default_input_device_info device_index = pa.get_default_input_device() IOError: No Default Input Device Available


what to do ?anyone can fix this

vishallight avatar Nov 30 '18 16:11 vishallight

You can try to find your input device index, and set input_device_index in the config. See #7 for more details

shichao-an avatar Dec 10 '18 23:12 shichao-an

You can try to find your input device index, and set input_device_index in the config. See #7 for more details

the input_device_index wont work because there are no input devices

hborah1 avatar Jul 11 '20 11:07 hborah1

hi programmers I have also the same issue in my google colab, -This is the full error-??

OSError Traceback (most recent call last) in () ----> 1 from speech_recognition import main

2 frames /usr/local/lib/python3.6/dist-packages/pyaudio.py in get_default_input_device_info(self) 947 """ 948 --> 949 device_index = pa.get_default_input_device() 950 return self.get_device_info_by_index(device_index) 951

OSError: No Default Input Device Available


how can I solve this error in colab

((----- :( I think I need to set input device and give permission to access it !

Can any one please help me!!

user-sam avatar Jul 26 '20 08:07 user-sam

Hi I am facing the same issue. Did it work ? If so please post a solution

savitha91 avatar Aug 24 '20 12:08 savitha91

Hi @savitha91, please tell me are you running your program in or you system or if you are running your program in online environment such as Google Collab or in kaggle kernal etc.

user-sam avatar Aug 24 '20 12:08 user-sam

Hi @savitha91, please tell me are you running your program in or you system or if you are running your program in online environment such as Google Collab or in kaggle kernal etc.

hi, i'm using google collab and how can i access my microphone using speech recognition from collab

bharathreddy3468 avatar Sep 10 '20 05:09 bharathreddy3468

hi programmers I have also the same issue in my google colab,

-This is the full error-?? OSError Traceback (most recent call last) in () ----> 1 from speech_recognition import main

2 frames /usr/local/lib/python3.6/dist-packages/pyaudio.py in get_default_input_device_info(self) 947 """ 948 --> 949 device_index = pa.get_default_input_device() 950 return self.get_device_info_by_index(device_index) 951

OSError: No Default Input Device Available

how can I solve this error in colab

((----- :( I think I need to set input device and give permission to access it !

Can any one please help me!!

even i have the same problem can anybody fix this

bharathreddy3468 avatar Sep 10 '20 05:09 bharathreddy3468

I found this piece of code exclusive to use local microphone via colab. Although I can't seem to extract the audio file without saving for my speech to text requirement.

`#in colab

!pip install ffmpeg-python import ffmpeg from IPython.display import HTML, Audio from google.colab.output import eval_js from base64 import b64decode import numpy as np from scipy.io.wavfile import read as wav_read import io

AUDIO_HTML = """

"""

def get_audio(): display(HTML(AUDIO_HTML)) data = eval_js("data") binary = b64decode(data.split(',')[1])

process = (ffmpeg .input('pipe:0') .output('pipe:1', format='wav') .run_async(pipe_stdin=True, pipe_stdout=True, pipe_stderr=True, quiet=True, overwrite_output=True) ) output, err = process.communicate(input=binary)

riff_chunk_size = len(output) - 8

Break up the chunk size into four bytes, held in b.

q = riff_chunk_size b = [] for i in range(4): q, r = divmod(q, 256) b.append(r)

Replace bytes 4:8 in proc.stdout with the actual size of the RIFF chunk.

riff = output[:4] + bytes(b) + output[8:]

sr, audio = wav_read(io.BytesIO(riff))

return audio, sr, riff

audio, sr, riff = get_audio()`

ShhrutiDeka avatar Dec 22 '20 04:12 ShhrutiDeka