Reputation: 11
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