pythonpyaudio

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!


Solution

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