Speech & Audio AI Lab

Interactive labs for speech recognition, speech synthesis, and audio in general: in-browser DSP experiments, algorithms, datasets, and a learning path, without storing any recording.

43experiments

WavLM

WavLM

AdvancedAcoustic Models

Educational content in the form of a scientific draft that needs expert review before being adopted as an academic reference. No experimental result that was not actually run is shown here.

Definition

A self-supervised speech model that predicts hidden units in the style of HuBERT, and adds prediction under noise or overlapping speech and a gated relative position bias, to improve non-speech tasks as well.

Mathematical Idea

During training, segments are created by mixing other speech or noise over the original segment, and the model is asked to predict the units of the original segment. This forces it to separate the target speech. Attention uses a gated relative position bias that depends on the content. The representations generalize to tasks such as speaker and separation.

How It Works

  1. Original segment and hidden units from clustering
  2. Mix speech or noise into part of the segment
  3. Mask time positions
  4. Transformer with attention that has a gated position bias
  5. Predict the units of the original segment
  6. Fine-tuning for downstream tasks

Stages Diagram

  1. Waveform + mixing
  2. Convolutional encoder
  3. Masking
  4. Transformer with gated bias
  5. Unit prediction

Equations

$$\tilde{x}=\mathrm{mix}(x,x_{noise})$$

Mixed segment; the target is the units extracted from $x$.

$$\mathcal{L}=-\sum_{t\in M}\log p(z_t\mid\tilde{x},t)$$

Loss on the masked positions.

Advantages

  • Representations suited to multiple tasks (speech/speaker/separation)
  • More robust to overlap and noise
  • Relies on unlabeled data

Limitations

  • Expensive pre-training
  • Higher complexity than HuBERT
  • Results vary by task

Use Cases

  • Speaker embeddings and diarization
  • Speech recognition
  • Non-speech tasks

Applied Example

In the mixed segment, the prediction target matches the units extracted from the original speech, not from the added speech.

Code Example

PythonIllustrative, not implemented in testing
import torch
from transformers import AutoFeatureExtractor, WavLMModel
name = "microsoft/wavlm-base"
fe = AutoFeatureExtractor.from_pretrained(name)
model = WavLMModel.from_pretrained(name).eval()
wave = torch.randn(16000).numpy()               # replace with a real 16 kHz recording
inp = fe(wave, sampling_rate=16000, return_tensors="pt")
with torch.no_grad():
    out = model(**inp, output_hidden_states=True)
# time average of an intermediate layer as a discriminative vector for the segment
emb = out.hidden_states[6].mean(dim=1)
print(emb.shape)

References

  1. Chen et al.. WavLM: Large-Scale Self-Supervised Pre-Training for Full Stack Speech Processing. arXiv (2021). DOI
  2. Hsu et al.. HuBERT: Self-Supervised Speech Representation Learning by Masked Prediction of Hidden Units. arXiv (2021). DOI
  3. Baevski et al.. wav2vec 2.0: A Framework for Self-Supervised Learning of Speech Representations. arXiv (2020). DOI

Audio processing in the experiments takes place inside your browser. Audio, texts, and conversations are not saved on the server. Privacy Policy