You can also break the sound into pieces and measure the RMS (measure of volume). let's say you want an image that is 180 pixels wide.
I will use pydub , a lightweight shell that I wrote around std lib wave
mode:
from pydub import AudioSegment
the for loop can be represented as the following list comprehension, I just wanted it to be clear:
loudness_of_chunks = [ sound[ i*chunk_length : (i+1)*chunk_length ].rms for i in range(180)]
Now we just have to think about whether to scale the RMS to a scale of 0 - 180 (since you want the image to be 180 pixels tall)
max_rms = max(loudness_of_chunks) scaled_loudness = [ (loudness / max_rms) * 180 for loudness in loudness_of_chunks]
I will leave a drawing of the actual pixels to you, I am not very experienced with PIL or ImageMagik: /
source share