【发布时间】:2019-06-05 08:04:06
【问题描述】:
例如,我有一个带语音的 wav 文件。
我可以用 sox 创建漂亮的频谱图可视化:
wget https://google.github.io/tacotron/publications/tacotron2/demos/romance_gt.wav
sox romance_gt.wav -n spectrogram -o spectrogram.png
如何在 python 中重现这个频谱图?
这里是使用scipy.signal.spectrogram的例子
input_file = 'temp/romance_gt.wav'
fs, x = wavfile.read(input_file)
print('fs', fs)
print('x.shape', x.shape)
f, t, Sxx = signal.spectrogram(x, fs)
print('f.shape', f.shape)
print('t.shape', t.shape)
print('Sxx.shape', Sxx.shape)
plt.pcolormesh(t, f, Sxx)
plt.ylabel('Frequency [Hz]')
plt.xlabel('Time [sec]')
plt.savefig('spectrogram_scipy.png')
【问题讨论】:
标签: python scipy sox spectrogram