This project demonstrates the Cocktail Party Problem β separating multiple mixed audio signals into their individual source signals using Independent Component Analysis (ICA) implemented from scratch in Python.
Given a set of mixed recordings (e.g., multiple people speaking simultaneously), ICA attempts to recover the original independent sources without knowing the mixing process.
- Uses Laplace prior via the
signnonlinearity to update the unmixing matrix. - Implements stochastic gradient ascent ICA without external ML libraries.
- Normalizes audio and saves both mixed and separated signals as
.wavfiles. - Simple and readable Python implementation.
- Demonstrates the classical blind source separation setup.
project/
βββ mix.dat # Input mixed audio signals (M samples Γ N channels)
βββ code.py # Main program (your code)
βββ output/ # Folder where results are saved
β βββ mixed_*.wav # Audio files for each mixture channel
β βββ split_*.wav # Recovered separated sources
β βββ W.txt # Learned unmixing matrix
βββ README.md # This file
The file mix.dat contains mixed signals.
They are normalized to the range [-1, 1] to prevent clipping.
ICA is applied using the update rule:
[ W \leftarrow W + \eta\left( (W^T)^{-1} - \text{sign}(Wx)x^T \right) ]
- Uses a schedule of decreasing learning rates (
anneallist). - Updates one sample at a time (stochastic gradient ascent).
- Produces an unmixing matrix
W.
Recovered sources are:
[ S = X W^T ]
These are normalized and saved as audio files.
pip install numpy scipyThis file should be shaped:
# rows = time samples
# columns = mixed audio channels
python main.pyYou will find:
mixed_0.wav,mixed_1.wav, β¦split_0.wav,split_1.wav, β¦W.txtβ the learned unmixing matrix
This is a basic ICA implementation using:
- Laplace density β score function
sign(y) - Stochastic gradient updates
- Annealing learning rates
- No whitening stage (the update rule compensates for it)
This demonstrates core ICA behavior without relying on high-level libraries such as scikit-learn.
Imagine placing multiple microphones in a noisy room where several people are speaking simultaneously. Each microphone captures a mixture of all voices.
ICA attempts to recover the original voices individually.
This project showcases exactly that.
- A. HyvΓ€rinen & E. Oja β Independent Component Analysis: Algorithms and Applications
- The classic βcocktail party problemβ