AttributeError: '_io.BufferedReader' object has no attribute
import wave
from zlib import compress
source = open("rickroll.wav", mode="rb")
nframes = source.getnframes()
source_frames = source.readframes(nframes)
data_compress = compress(source_frames, level=6)
fout = open('nto.bin', 'w')
print(data_compress, file=fout)
fout.close()
данный код выдает ошибку
File "C:\Users\...", line 6, in <module>
nframes = source.getnframes()
AttributeError: '_io.BufferedReader' object has no attribute 'getnframes'
подскажите решение
используя wave.open()
File "C:\Users\1-ПК\PycharmProjects\pythonProject\cringe\new.py", line 5, in <module>
source = wave.open("rickroll.wav", mode="rb")
File "C:\Users\1-ПК\python38\lib\wave.py", line 509, in open
return Wave_read(f)
File "C:\Users\1-ПК\python38\lib\wave.py", line 163, in __init__
self.initfp(f)
File "C:\Users\1-ПК\python38\lib\wave.py", line 128, in initfp
self._file = Chunk(file, bigendian = 0)
File "C:\Users\1-ПК\python38\lib\chunk.py", line 63, in __init__
raise EOFError
EOFError
Process finished with exit code 1