Change the volume of a wav file in python

前端 未结 3 1001
醉梦人生
醉梦人生 2020-12-25 15:36

I have a 2 seconds 16bit single channel 8khz wav file and I need to change its volume.

It should be quite straightforward, because changing the volume is the same as

3条回答
  •  离开以前
    2020-12-25 16:10

    As you can see in the comments of the question, there are several solutions, some more efficient.

    The problem was immediately detected by Jan Dvorak ("the * 5 part is clipping and overflowing") and the straightforward solution was:

    s = numpy.fromstring(s, numpy.int16) / 10 * 5
    

    In this case, this solution was perfect for me, just good enough.

    Thank you all folks!

提交回复
热议问题