TakwayBoard/tools/audio_ayalize.py

15 lines
542 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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