shichao-an / soundmeter

Simple real-time sound meter
https://soundmeter.shichao.io
BSD 2-Clause "Simplified" License
82 stars 27 forks source link

python---IOError: No Default Input Device Available #25

Open vishallight opened 5 years ago

vishallight commented 5 years ago

~# 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

shichao-an commented 5 years ago

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

hborah1 commented 4 years ago

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

user-sam commented 4 years ago

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!!
savitha91 commented 4 years ago

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

user-sam commented 4 years ago

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.

bharathreddy3468 commented 4 years ago

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 commented 4 years ago

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

ShhrutiDeka commented 3 years ago

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()`