speechbrain.nnet.loss.stoi_loss 模块

用于计算STOI的库。 参考:“端到端波形语句增强用于直接评估指标优化通过全卷积神经网络”,TASLP,2018年

Authors:

Szu-Wei, Fu 2020

摘要

函数:

removeSilentFrames

从STOI计算中移除静音帧。

stoi_loss

计算STOI分数并返回-1乘以该分数。

thirdoct

返回1/3倍频带矩阵。

参考

speechbrain.nnet.loss.stoi_loss.thirdoct(fs, nfft, num_bands, min_freq)[source]

返回1/3倍频带矩阵。

Parameters:
  • fs (int) – 采样率。

  • nfft (int) – FFT 大小。

  • num_bands (int) – 1/3倍频带的数量。

  • min_freq (int) – 最低1/3倍频带的中心频率。

Returns:

obm – 八度带矩阵。

Return type:

张量

speechbrain.nnet.loss.stoi_loss.removeSilentFrames(x, y, dyn_range=40, N=256, K=128)[source]

从STOI计算中移除静音帧。

此函数可用作基于SGD更新的训练损失函数。

Parameters:
  • x (torch.Tensor) – 干净的(参考)波形。

  • y (torch.Tensor) – 退化(增强)后的波形。

  • dyn_range (int) – 用于掩码计算的动态范围。

  • N (int) – 窗口长度。

  • K (int) – 步长。

Return type:

包含2个元素的列表,x和y,已去除静音。

speechbrain.nnet.loss.stoi_loss.stoi_loss(y_pred_batch, y_true_batch, lens, reduction='mean')[source]

计算STOI分数并返回-1乘以该分数。

此函数可用作基于SGD更新的训练损失函数。

Parameters:
  • y_pred_batch (torch.Tensor) – 退化(增强)的波形。

  • y_true_batch (torch.Tensor) – 干净的(参考)波形。

  • lens (torch.Tensor) – 批次中波形的相对长度。

  • reduction (str) – 使用的减少类型(“mean”或“batch”)。

Return type:

计算出的STOI损失。

Example

>>> a = torch.sin(torch.arange(16000, dtype=torch.float32)).unsqueeze(0)
>>> b = a + 0.001
>>> -stoi_loss(b, a, torch.ones(1))
tensor(0.7...)