更新时间:2022-06-05 22:23:21
是的,可以恢复大部分信号并使用例如Griffin-Lim算法(GLA).可以在 librosa 中找到其针对Python的快速"实现.使用方法如下:
Yes, it is possible to recover most of the signal and estimate the phase with e.g. Griffin-Lim Algorithm (GLA). Its "fast" implementation for Python can be found in librosa. Here's how you can use it:
import numpy as np
import librosa
y, sr = librosa.load(librosa.util.example_audio_file(), duration=10)
S = np.abs(librosa.stft(y))
y_inv = librosa.griffinlim(S)
这就是原始和重建的样子:
And that's how the original and reconstruction look like:
默认情况下,该算法会随机初始化相位,然后反复进行正向和反向STFT操作以估计相位.
The algorithm by default randomly initialises the phases and then iterates forward and inverse STFT operations to estimate the phases.
查看您的代码以重构信号,您只需要执行以下操作:
Looking at your code, to reconstruct the signal, you'd just need to do:
import numpy as np
X_inv = librosa.griffinlim(np.abs(X))
这只是一个例子.正如@PaulR所指出的,在您的情况下,您需要从jpeg
加载数据(这是有损的!),然后首先对amplitude_to_db
应用逆变换.
It's just an example of course. As pointed out by @PaulR, in your case you'd need to load the data from jpeg
(which is lossy!) and then apply inverse transform to amplitude_to_db
first.
由于人工神经网络的进步,可以进一步改善算法,尤其是相位估计. 此处是讨论某些增强功能的论文.
The algorithm, especially the phase estimation, can be further improved thanks to advances in artificial neural networks. Here is one paper that discusses some enhancements.