谱减法(二)

由于第一种谱减法中存在音乐噪声难以去除,故利用过减法来进一步去除噪声。

Px(ω)=(PY(ω)γαPE(ω)γ)1γα46P_x(\omega)=(P_Y(\omega)^\gamma-\alpha P_E(\omega)^\gamma)^\frac{1}{\gamma},其中\alpha取值为4 – 6
PX(ω)={βPE(ω),PX(ω)<βPE(ω)PX(ω),otherwise其中 β[0.0001,0.001]P_X(\omega) = \begin{cases} \beta P_E(\omega), & P_X(\omega) < \beta P_E(\omega) \\ P_X(\omega), & \text{otherwise} \end{cases} \qquad \text{其中 } \beta \in [0.0001, 0.001]
|X(ω)|=PX(ω)|X(\omega)|=\sqrt {P_X(\omega)}
    #subtract the noise power from the noisy power   
    #use over_subtraction method to enhance the signal
    alpha = 4
    gamma = 1
    beta = 0.0001

    power_enhanc = np.power(power_noisy, gamma) - alpha * np.power(power_noise, gamma)
    power_enhanc = np.power(power_enhanc, 1/gamma)
    #use beta*power_noise to instead of small negative values
    mask = (power_enhanc >= beta * power_noise) - 0
    print(mask.shape)
    power_enhanc = mask * power_enhanc + (1-mask) * beta * power_noise
    Mag_enhanc = np.sqrt(power_enhanc)

主要实现如图所示

由于过减,造成其谱线不连续,所以要进行平滑机制

最大噪声残差

max(ω)=argmaxt=0TnoiseEt(ω)E(ω)E(ω)是估计的噪声,也就是 Et(ω)的均值max(\omega)=arg\,max\sum_{t=0}^{T_{noise}}E_t(\omega)-E(\omega)\qquad E(\omega)\text{是估计的噪声,也就是 } E_t(\omega)\text{的均值}
|X(ω)|={argmintkt+k|Xt(ω)||X(ω)|<max(ω)|X(ω)|otherwise|X(\omega)|= \begin{cases} arg\,min\sum_{t-k}^{t+k}|X_t(\omega)| &|X(\omega)|<max(\omega)\\ |X(\omega)| &\text{otherwise} \end{cases}
    ## introduce the smoothing method to enhance the signal
    Mag_noisy_new = np.copy(Mag_noisy)
    k = 1
    for t in range(k,T-k):
        Mag_noisy_new[:,t] = np.mean(Mag_noisy[:,t-k:t+k+1], axis=1)

    power_noisy = Mag_noisy_new**2
 # compute the max
    Mag_enhanc_new = np.copy(Mag_enhanc)
    maxnr = np.max(np.abs(noisy_stft[:,:31])-Mag_noise,axis = 1)
    k = 1
    for t in range(k,T-k):
        index =np.where(Mag_enhanc[:,t] < maxnr)[0]
        temp =np.min(Mag_enhanc[:,t-k:t+k+1], axis=1)
        Mag_enhanc_new[index,t] = temp[index]
        enhanc_stft = Mag_enhanc_new * np.exp(1j*Phase_noisy)
    enhanc = librosa.istft(enhanc_stft, hop_length=128,win_length=256)
    sf.write("enhanc3.wav", enhanc, fs)
    print(fs)

降噪效果得到明显改善

类似文章

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注