How to select a specific input device with PyAudio

you can use get_device_info_by_host_api_device_index. For instance: import pyaudio p = pyaudio.PyAudio() info = p.get_host_api_info_by_index(0) numdevices = info.get(‘deviceCount’) for i in range(0, numdevices): if (p.get_device_info_by_host_api_device_index(0, i).get(‘maxInputChannels’)) > 0: print(“Input Device id “, i, ” – “, p.get_device_info_by_host_api_device_index(0, i).get(‘name’))

PyAudio Input overflowed

pyaudio.Stream.read() has a keyword parameter exception_on_overflow, set this to False. For your sample code that would look like: import pyaudio import wave import sys chunk = 1024 FORMAT = pyaudio.paInt16 CHANNELS = 1 RATE = 44100 RECORD_SECONDS = 5 WAVE_OUTPUT_FILENAME = “output.wav” p = pyaudio.PyAudio() stream = p.open(format = FORMAT, channels = CHANNELS, rate = … Read more

How can the terminal output of executables run by Python functions be silenced in a general way?

For the ALSA errors in particular, you can use ALSA’s snd_lib_error_set_handler function as described for example in this question. For one of my projects, I created a module called mute_alsa, which looks like this: import ctypes ERROR_HANDLER_FUNC = ctypes.CFUNCTYPE(None, ctypes.c_char_p, ctypes.c_int, ctypes.c_char_p, ctypes.c_int, ctypes.c_char_p) def py_error_handler(filename, line, function, err, fmt): pass c_error_handler = ERROR_HANDLER_FUNC(py_error_handler) try: … Read more