2 years ago
#63491
PrisTheMan
I have this error: struct.error: unpack requires a buffer of 4 bytes when trying to decode a .wav file
Basically what I'm trying to do is get information about the .wav file and output it so i found this Stack Overflow question and followed the second most popular post because it seemed to be what i wanted however, I am getting this error:
- data = struct.unpack("f", "a".encode("ascii")) struct.error: unpack requires a buffer of 4 bytes
when running the program.
Here is the code:
wavefile = wave.open('music.wav', 'r')
length = wavefile.getnframes()
for i in range(0, length):
wavedata = wavefile.readframes(1)
data = struct.unpack("f", "a".encode("ascii"))
#data = struct.unpack("<h", wavedata)
print(int(data[0]))```
python
wav
bytebuffer
0 Answers
Your Answer