2024-05-23 01:27:51 +08:00
|
|
|
|
import wave
|
|
|
|
|
# 读取wave文件,并打印采样率、量化位数、声道数
|
|
|
|
|
# 读取wave文件,并打印data长度
|
2024-05-27 05:57:45 +08:00
|
|
|
|
with wave.open('output.wav', 'rb') as f:
|
2024-05-23 01:27:51 +08:00
|
|
|
|
data = f.readframes(f.getnframes())
|
|
|
|
|
print(len(data))
|
|
|
|
|
print(type(data))
|
|
|
|
|
nchannels, sampwidth, framerate, nframes, comptype, compname = f.getparams()
|
2024-05-27 05:57:45 +08:00
|
|
|
|
print("采样率:", framerate)
|
|
|
|
|
print("量化位数:", sampwidth)
|
|
|
|
|
print("声道数:", nchannels)
|
|
|
|
|
print("data长度:", nframes)
|
|
|
|
|
print("压缩类型:", comptype)
|
|
|
|
|
print("压缩名称:", compname)
|