所以我只需要将adjusted_fft_frames = mag_frames * np.exp(1j * 2 * np.pi * pitch_freqs_smoothed[:, np.newaxis] * freqs[np.newaxis, :])这段代码替换成pitch_freqs_smoothed = pitch_freqs_smoothed[:, np.newaxis]pitch_freqs_smoothed = np.tile(pitch_freqs_smoothed, (1, mag_frames.shape[1]))adjusted_fft_frames = mag_frames * np.exp(1j * 2 * np.pi * pitch_freqs_smoothed * freqs[np.newaxis, :])就行了吗
时间: 2024-02-12 09:08:05 浏览: 105
intel_panel.rar_Linux/Unix编程_Unix_Linux_
是的,你可以将原来的代码替换为新的代码,但是需要注意一下 `freqs` 数组的长度是否正确,以确保可以正确进行广播操作。同时,也需要确保 `pitch_freqs_smoothed` 被正确地转换为 `(198, 882)` 的形状。
完整的代码修改如下:
```
freqs = np.fft.rfftfreq(n_fft, d=1.0/sr)
pitch_freqs_smoothed = pitch_freqs_smoothed[:, np.newaxis]
pitch_freqs_smoothed = np.tile(pitch_freqs_smoothed, (1, mag_frames.shape[1]))
adjusted_fft_frames = mag_frames * np.exp(1j * 2 * np.pi * pitch_freqs_smoothed * freqs[np.newaxis, :])
```
这个修改后的代码会将 `pitch_freqs_smoothed` 转换为一个形状为 `(198, 882)` 的数组,然后使用广播机制将其与 `freqs` 相乘,得到一个形状为 `(198, 882)` 的新的振幅谱矩阵 `adjusted_fft_frames`。
阅读全文