I want to use Python to access a wav-file and write its content in a form which allows me to analyze it (let\'s say arrays).
I wrote a simple wrapper over the wave module in the std lib. it's called pydub and it has a method for reading samples from the audio data as ints.
>>> from pydub import AudioSegment
>>> song = AudioSegment.from_wav("your_song.wav")
>>> # This song is stereo
>>> song.channels
2
>>> # get the 5000th "frame" in the song
>>> frame = song.get_frame(5000)
>>> sample_left, sample_right = frame[:2], frame[2:]
>>> def sample_to_int(sample):
return int(sample.encode("hex"), 16)
>>> sample_to_int(sample_left)
8448
>>> sample_to_int(sample_right)
9984
Hopefully this helps