显示同一段语音,不同说话人对比下效果
波形图
import wave
import matplotlib.pyplot as plt
import numpy as np
from scipy.io import wavfile
"""读取双通道波形并绘制波形图"""
f = wavfile.read("./test1.wav")
nframes = len(f[1]) #获取采样点数
nchannels = 1 # 通道数=1
framerate = f[0] # 获取采样频率
wave_data = f[1] # 获取音频数据
wave_data = np.reshape(wave_data, [nframes, nchannels])
# 最后通过采样点数和取样频率计算出每个取样的时间
time = np.arange(0, nframes) * (1.0 / framerate)
plt.figure()
plt.subplot(3, 1, 1)
plt.plot(time, wave_data[:, 0])
plt.xlabel("time (seconds)")
plt.ylabel("Amplitude")
plt.title("people_one")
plt.grid() # 标尺
plt.subplot(3, 1, 3)
f = wavfile.read("./test2.wav")
nframes = len(f[1]) #获取采样点数
nchannels = 1 # 通道数=1
framerate = f[0]