python - 如何可视化和选择参数谱图张量流
问题描述
我有 3 分钟持续时间的音频,我有波形形状:(2880000,) 那么 frame_length 和 frame_step 的值应该是多少
spectrogram = tf.signal.stft(waveform, frame_length=?, frame_step=?)
spectrogram = tf.abs(spectrogram)
在选择 frame_length=255 & frame_step=128 我得到频谱图形状为 22499,129 并且当我尝试可视化
def plot_spectrogram(spectrogram, ax):
# Convert to frequencies to log scale and transpose so that the time is
# represented in the x-axis (columns).
log_spec = np.log(spectrogram.T)
height = log_spec.shape[0]
X = np.arange(2880000, step=height + 1)
Y = range(height)
ax.pcolormesh(X, Y, log_spec)
fig, axes = plt.subplots(2, figsize=(12, 8))
timescale = np.arange(audio.shape[0])
axes[0].plot(timescale, audio.numpy())
axes[0].set_title('Waveform')
axes[0].set_xlim([0, 2880000])
plot_spectrogram(spectrogram.numpy(), axes[1])
axes[1].set_title('Spectrogram')
plt.show()
我收到这个错误 Dimensions of C (129, 22499) are incompatible with X (22154) and/or Y (129); see help(pcolormesh)
所以问题是如何选择参数然后可视化
解决方案
推荐阅读
- phpmyadmin - phpMyAdmin 无法识别主键
- sublimetext3 - 复杂的按键序列
- javascript - 如何使用jquery添加一个类来锚定父级的第一个单词?
- swift - appleTV:URLSession.shared.dataTask 下载为空
- node.js - 反应新项目对 ^6.14.0 的依赖 || ^8.10.0 || >=9.10.0
- css - Styled-components 多个伪元素
- php - 有关涉及语法的面向对象 PHP 的问题
- c# - NLog UWP 手动删除/导出日志
- oracle - 安装 ODT 时出现 Oracle 客户端错误 [INS-50016]
- node.js - 如何处理使用 REST API 但需要实时聊天的应用程序 (Socket.io)