Parsa Esmaili
Parsa Esmaili

Reputation: 11

How can I change the volume of a stream playing in pyaudio

I have a normal stream in Pyaudio that plays a wav file but I can not find any way to change the volume of the stream. I tried multiplying the data by some number but that did not work.

import pyaudio
import wave

audio = pyaudio.PyAudio()
chunk = 1024
af = wave.open("filename.wav", 'rb')
pa = pyaudio.PyAudio()

stream = pa.open(format = 
pa.get_format_from_width(af.getsampwidth()),
            channels = af.getnchannels(),
            rate = af.getframerate(),
            output_device_index=9,
            output = True)

rd_data = af.readframes(chunk)

while rd_data != '':
    #do some majic to change the volume
    stream.write(rd_data)
    rd_data = af.readframes(chunk)

Upvotes: 1

Views: 565

Answers (0)

Related Questions