python 音频数据归一化

import copy
import numpy as np
from scipy.io import wavfile
import matplotlib.pyplot as plt

fs, data = wavfile.read(r'./data/童年.wav')

plt.figure()
plt.subplot(2,1,1)
plt.plot(data)

xx = copy.deepcopy(data)
xx = xx - np.mean(xx)     # 消除直流分量
x = xx/np.max(np.abs(xx)) # 幅值归一化

plt.subplot(2,1,2)
plt.plot(x)
plt.show()

你可能感兴趣的:(python)