在 GitHub 上执行或查看/下载此 Notebook
环境损坏
在真实的语音处理场景中,麦克风捕获的信号经常会受到噪声和混响等不需要的元素的干扰。在远场(far-field)场景中,这种挑战尤为突出,因为说话人和参考麦克风之间的距离很大。此类场景的例子包括 Google Home、Amazon Echo、Kinect 等流行设备记录的信号。
神经语音处理中常用的策略是从干净的语音录音开始,然后人工引入噪声和混响来模拟真实世界条件。这个过程被称为环境损坏或语音污染。
从干净的信号开始,可以控制性地引入各种类型的噪声和混响,使环境损坏成为一种有效的正则化技术。这种正则化有助于神经网络在测试期间暴露于真实世界、嘈杂的条件下时获得更好的泛化能力。
环境损坏过程使用以下公式将干净信号 \(x[n]\) 转换为嘈杂和混响的信号
\(y[n] = x[n] * h[n] + n[n]\)
其中 \(n[n]\) 表示噪声序列,\(h[n]\) 是引入混响效应的脉冲响应。
在以下章节中,我们将深入探讨如何执行这种转换的细节。在此之前,让我们下载一些对本教程其余部分至关重要的信号。
%%capture
!wget https://www.dropbox.com/s/vwv8xdr7l3b2tta/noise_sig.csv
!wget https://www.dropbox.com/s/aleer424jumcs08/noise2.wav
!wget https://www.dropbox.com/s/eoxxi2ezr8owk8a/noise3.wav
!wget https://www.dropbox.com/s/pjnub2s5hql2vxs/rir1.wav
!wget https://www.dropbox.com/s/nyno6bqbmiy2rv8/rirs.csv
!wget https://www.dropbox.com/s/u8qyvuyie2op286/spk1_snt1.wav
%%capture
# Installing SpeechBrain
BRANCH = 'develop'
!git clone https://github.com/speechbrain/speechbrain.git -b $BRANCH
%cd /content/speechbrain/
!python -m pip install .
干净语音信号如下所示
import matplotlib.pyplot as plt
from speechbrain.dataio.dataio import read_audio
from IPython.display import Audio
clean = read_audio('/content/spk1_snt1.wav').squeeze()
# Plots
plt.subplot(211)
plt.plot(clean)
plt.xlabel('Time')
plt.subplot(212)
plt.specgram(clean,Fs=16000)
plt.xlabel('Time')
plt.ylabel('Frequency')
Audio(clean, rate=16000)
1. 加性噪声
在 SpeechBrain 中,我们设计了一个能够用噪声污染语音信号的类(speechbrain.augment.time_domanin.AddNoise
)。此类以 csv 文件作为输入,该文件列出了噪声信号列表
ID, duration, wav, wav_format, wav_opts
noise2, 5.0, noise2.wav, wav,
noise3, 1.0, noise3.wav, wav,
调用时,AddNoise
从噪声集合中采样,并以随机的信噪比(SNR)将选定的噪声添加到干净信号中。
import torch
from speechbrain.augment.time_domain import AddNoise
noisifier = AddNoise('tests/samples/annotation/noise.csv', replacements={'noise_folder': 'tests/samples/noise'})
noisy = noisifier(clean.unsqueeze(0), torch.ones(1))
# Plots
plt.subplot(211)
plt.plot(noisy.squeeze())
plt.xlabel('Time')
plt.subplot(212)
plt.specgram(noisy.squeeze(),Fs=16000)
plt.xlabel('Time')
plt.ylabel('Frequency')
Audio(noisy.squeeze(0), rate=16000)
噪声量可以通过snr_low和snr_high参数进行调整,这些参数定义了信噪比的采样范围。需要长度向量,因为我们可以并行处理不同长度的信号批次。长度向量包含批次中每个句子的相对长度(例如,对于两个示例,我们可以有 length=[0.8 1.0],其中 1.0 是批次中最长句子的长度)。
2. 混响
当在房间里说话时,我们的语音信号会受到墙壁、地板、天花板以及声学环境中的物体多次反射。因此,远距离麦克风记录的最终信号将包含原始信号的多个延迟副本。所有这些副本相互干扰,显著影响语音信号的可懂度。
这种多径传播称为混响。在给定的房间环境中,源和接收器之间的混响通过脉冲响应建模
rir = read_audio('/content/rir1.wav')
# Impulse response
plt.subplot(211)
plt.plot(rir[0:8000])
plt.xlabel('Time')
plt.ylabel('h(t)')
# Zoom on early reflections
plt.subplot(212)
plt.plot(rir[2150:2500])
plt.xlabel('Time')
plt.ylabel('h(t)')
脉冲响应完整描述了声音从声源传播到接收器时经历的变化。特别是,脉冲响应中的每个峰值对应于到达接收器的一个副本。第一个峰值对应于直达路径。然后,我们可以看到墙壁、天花板、地板上的一阶反射(参见第二张图)。
总体而言,脉冲响应遵循指数衰减。这种衰减在混响时间短的干燥房间中更快,而在大型空旷环境中则更慢。
通过对干净信号和脉冲响应进行卷积来添加混响。在 SpeechBrain 中,此操作由 speechbrain.processing.speech_augmentation.AddReverb
执行。
调用时,AddRev
从给定的 csv 文件中采样一个脉冲响应
ID, duration, wav, wav_format, wav_opts
rir1, 1.0, rir1.wav, wav,
....
from speechbrain.augment.time_domain import AddReverb
reverb = AddReverb('tests/samples/annotation/RIRs.csv', replacements={'rir_folder': 'tests/samples/RIRs'})
reverbed = reverb(clean)
# Plots
plt.subplot(211)
plt.plot(reverbed.squeeze())
plt.xlabel('Time')
plt.subplot(212)
plt.specgram(reverbed.squeeze(),Fs=16000)
plt.xlabel('Time')
plt.ylabel('Frequency')
Audio(reverbed.squeeze(0), rate=16000)
混响是一种卷积噪声,它在时域(参见干净信号中沉默区域出现的长尾巴)和频域中“平滑”信号。
混响量由参数rir_scale_factor控制。如果 rir_scale_factor < 1,脉冲响应被压缩(混响较少),而如果 rir_scale_factor > 1,脉冲响应被拉伸(混响较多)。请随意在上一个示例中尝试!
参考文献
[1] M. Ravanelli, P. Svaizer, M. Omologo, “Realistic Multi-Microphone Data Simulation for Distant Speech Recognition”,收录于 Interspeech 2016 ArXiv 会议论文集
[2] M. Ravanelli, M. Omologo, “Contaminated speech training methods for robust DNN-HMM distant speech recognition”,收录于 INTERSPEECH 2015 ArXiv 会议论文集。
[3] M. Ravanelli, M. Omologo, “On the selection of the impulse responses for distant-speech recognition based on contaminated speech training”,收录于 INTERSPEECH 2014 ArXiv 会议论文集。
[4] M. Ravanelli, A. Sosi, P. Svaizer, M.Omologo, “Impulse response estimation for robust speech recognition in a reverberant environment”,收录于 European Signal Processing Conference, EUSIPCO 2012 ArXiv 会议论文集。
引用 SpeechBrain
如果您在研究或商业中使用 SpeechBrain,请使用以下 BibTeX 条目引用:
@misc{speechbrainV1,
title={Open-Source Conversational AI with {SpeechBrain} 1.0},
author={Mirco Ravanelli and Titouan Parcollet and Adel Moumen and Sylvain de Langen and Cem Subakan and Peter Plantinga and Yingzhi Wang and Pooneh Mousavi and Luca Della Libera and Artem Ploujnikov and Francesco Paissan and Davide Borra and Salah Zaiem and Zeyu Zhao and Shucong Zhang and Georgios Karakasidis and Sung-Lin Yeh and Pierre Champion and Aku Rouhe and Rudolf Braun and Florian Mai and Juan Zuluaga-Gomez and Seyed Mahed Mousavi and Andreas Nautsch and Xuechen Liu and Sangeet Sagar and Jarod Duret and Salima Mdhaffar and Gaelle Laperriere and Mickael Rouvier and Renato De Mori and Yannick Esteve},
year={2024},
eprint={2407.00463},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/2407.00463},
}
@misc{speechbrain,
title={{SpeechBrain}: A General-Purpose Speech Toolkit},
author={Mirco Ravanelli and Titouan Parcollet and Peter Plantinga and Aku Rouhe and Samuele Cornell and Loren Lugosch and Cem Subakan and Nauman Dawalatabad and Abdelwahab Heba and Jianyuan Zhong and Ju-Chieh Chou and Sung-Lin Yeh and Szu-Wei Fu and Chien-Feng Liao and Elena Rastorgueva and François Grondin and William Aris and Hwidong Na and Yan Gao and Renato De Mori and Yoshua Bengio},
year={2021},
eprint={2106.04624},
archivePrefix={arXiv},
primaryClass={eess.AS},
note={arXiv:2106.04624}
}