V
V
Vadim)))2021-11-23 16:20:43
Python
Vadim))), 2021-11-23 16:20:43

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

Reboot saved. I have Windows 10.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question