Answer the question
In order to leave comments, you need to log in
Why are audio devices turned off when I run the pyaudio library?
I am writing a program using the PyAudio module. When running the test program, sound devices flew out:
import pyaudio
from pprint import pprint
p = pyaudio.PyAudio()
pprint(p.is_format_supported(input_format=pyaudio.paInt8,
input_channels=1,
rate=44100,
input_device=0))
try:
stream = p.open(format=pyaudio.paInt8,
channels=1,
rate=44100,
input=True,
input_device_index=0,
frames_per_buffer=1024)
data = stream.read(1024)
except IOError as e:
print(e)
stream.stop_stream()
stream.close()
pprint(p.is_format_supported(input_format=pyaudio.paInt8,
input_channels=1,
rate=22050,
input_device=0))
try:
stream = p.open(format=pyaudio.paInt8,
channels=1,
rate=22050,
input=True,
input_device_index=0,
frames_per_buffer=1024)
data = stream.read(1024)
except IOError as e:
print(e)
stream.stop_stream()
stream.close()
p.terminate()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question