from scipy.io.wavfile import read as wavread
from scipy.io.wavfile import write as wavwrite
import numpy as np
sr, sig = wavread(audioFileName) #read the audio file (samplig rate, signal)
sig_int8 = np.uint8(sig) # cast the data in uint8
np.savez(out_file, sig = sig_int8) # store the data
npzfile = np.load(out_file + '.npz') #load the data
sig = npzfile['sig']
wavwrite(audioFileName2, sr, sig) #write data in wav file
你可以用波浪读写wav文件。要存储数据,可以使用numpy。在
如果音频文件有效编码为每个样本16位,则无需执行任何操作,这应该类似于:
相关问题 更多 >
编程相关推荐