1)scipy
from scipy.io import wavfile
import numpy as np
sample_rate, sig = wavfile.read('new.wav')
print("采样率: %d" % sample_rate)
print(sig)
if sig.dtype == np.int16:
print("PCM16位整形")
if sig.dtype == np.float32:
print("PCM32位浮点")
输出如下:
采样率: 16000
[-1466 -733 -733 ... 2199 1832 1466]
PCM16位整形
2)pysoundfile
import soundfile as sf
sig, sample_rate = sf.read('new.wav')
print("采样率:%d" % sample_rate)
print(sig)
输出如下:
采样率:16000
[-0.04473877 -0.02236938 -0.02236938 ... 0.06710815 0.0559082
0.04473877]
3)wave
不推荐此库
------------------------------------------------分割线-----------------------------------------------
WAV格可以用16位整形或者32