劣质的麦克风在录音时会把电流和嗡嗡的背景声录进去,通过对噪声取样去除频率可以达到降噪的目的。

主要步骤:

1. 噪声取样

2. 统计频率

3. 移除频率

代码如下:
'''采样降噪''' def test2(n, y, sr): indexs = librosa.effects.split(y, top_db=25-n)
noicefrequencies = [] for i in indexs: frequencies, D =
librosa.ifgram(y[i[0]:i[1]], sr=sr, n_fft=22000) frequencies =
frequencies.astype(int) noicefrequencies += frequencies.flatten().tolist() c =
Counter(noicefrequencies) noicefrequencies = set(map(lambda x: x[0] // 2 * 2,
c.most_common(400))) frequencies, D = librosa.ifgram(y, sr=sr) tempD =
D.copy().astype(int) tempD = tempD // 2 * 2 count = 0 for i in
range(D.shape[0]): for j in range(D.shape[1]): if tempD[i][j] in
noicefrequencies: count += 1 D[i][j] = 0 print(count) return librosa.istft(D)

 

技术
友情链接
码工具
Toolsou
API参考文档
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:ixiaoyang8@qq.com
QQ群:766591547
关注微信