简体   繁体   中英

How do I configure an output device for PyAudio

I have been looking for a method to play a wavfile on a specific output-device using a PyAudio-stream. The documentation of the stream-class initialization hasn't provided any further information:( The wav file playing part is done, so the only thing that remains is the device configuration Thanks in advance!

Came up with the solution myself:

You gotta pass the keyword argument "output_device_index" into the stream class constructor Namely:

p = pyaudio.PyAudio()
stream = p.open(
    format              = p.get_format_from_width(wf.getsampwidth()),
    channels            = wf.getnchannels(),
    rate                = wf.getframerate(),
    output              = True,
    output_device_index = 16
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM