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

Gaussian Mixture Model

Gaussian Mixture Model (GMM)

IntermediateMachine Learning

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 probabilistic model that represents the feature distribution as a weighted sum of several Gaussian distributions. It is estimated with the expectation-maximization (EM) algorithm.

Mathematical Idea

$p(x)=\sum_k \pi_k\,\mathcal N(x;\mu_k,\sigma_k^2)$. In the E step we compute the responsibility of each component $\gamma_{ik}=\pi_k\mathcal N_{ik}/\sum_j\pi_j\mathcal N_{ij}$, and in the M step we update the weights, means, and variances weighted by the responsibilities. Each iteration does not decrease the likelihood. The solution is affected by initialization and may get stuck in a local maximum.

How It Works

  1. Initialize $\pi,\mu,\sigma^2$.
  2. E step: compute the responsibilities.
  3. M step: update the parameters.
  4. Repeat until the likelihood converges.
  5. Use the model to compute the likelihood for each class.

Stages Diagram

  1. Features
  2. Initialization
  3. E Step
  4. M Step
  5. Convergence

Equations

$$p(x)=\sum_{k=1}^{K}\pi_k\,\mathcal N(x\mid\mu_k,\sigma_k^2)$$

$\pi_k$ are the component weights and they sum to 1.

$$\gamma_{ik}=\frac{\pi_k\,\mathcal N(x_i\mid\mu_k,\sigma_k^2)}{\sum_j \pi_j\,\mathcal N(x_i\mid\mu_j,\sigma_j^2)}$$

The posterior responsibility (E step).

$$\mu_k=\frac{\sum_i\gamma_{ik}x_i}{\sum_i\gamma_{ik}}$$

Mean update (M step).

Advantages

  • A probabilistic model that gives the likelihood.
  • Represents multimodal distributions.
  • A historical foundation for GMM-HMM and speaker systems.

Limitations

  • Requires choosing $K$.
  • Sensitive to initialization and local maxima.
  • Full-covariance formulations are expensive.

Use Cases

  • Speaker modeling (educational).
  • Modeling emission probabilities in HMMs.
  • Unsupervised feature clustering.

Applied Example

Two components with weight 0.5, means 0 and 4, and variance 1: at $x=1$ the responsibility is $\gamma_1=e^{-0.5}/(e^{-0.5}+e^{-4.5})\approx0.982$.

Code Example

PythonImplemented and Tested
import numpy as np
rng = np.random.default_rng(0)
x = np.concatenate([rng.normal(0, 1, 300), rng.normal(5, 1.5, 200)])
pi, mu, var = np.array([0.5, 0.5]), np.array([-1.0, 6.0]), np.array([1.0, 1.0])
def pdf(x, m, v):
    return np.exp(-(x - m)**2/(2*v))/np.sqrt(2*np.pi*v)
for _ in range(50):
    p = np.stack([pi[k]*pdf(x, mu[k], var[k]) for k in range(2)])   # E step
    r = p/p.sum(axis=0)
    Nk = r.sum(axis=1)                                              # M step
    pi, mu = Nk/len(x), (r @ x)/Nk
    var = np.array([(r[k]*(x - mu[k])**2).sum()/Nk[k] for k in range(2)])
print("weights:", np.round(pi, 2))
print("means  :", np.round(mu, 2))
print("stds   :", np.round(np.sqrt(var), 2))

References

  1. Reynolds, Quatieri, Dunn. Speaker Verification Using Adapted Gaussian Mixture Models. Digital Signal Processing (2000). DOI
  2. Rabiner. A tutorial on hidden Markov models and selected applications in speech recognition. Proceedings of the IEEE 77(2):257-286 (1989). DOI
  3. McFee, Raffel, Liang, Ellis, McVicar, Battenberg, et al.. librosa: Audio and Music Signal Analysis in Python. Proceedings of the 14th Python in Science Conference (2015). DOI

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