How can I use width 2 to get result without error?
The width is 2, but I will get error.
If I change it to 1, I can get a result from the code but its incorrect.
import wave
import contextlib
import audioop
fname = "some.wav"
with contextlib.closing(wave.open(fname,'r')) as f:
frames = f.getnframes()
rate = f.getframerate()
duration = frames / float(rate)
width = f.getsampwidth()
channel = f.getnchannels()
size = width*channel
# f.rewind()
wav = f.readframes(f.getnframes())
# print(duration)
print(audioop.rms(str(wav).encode("ascii"),2))
"audioop.error: not a whole number of frames"