Skip to content

πŸŽ›οΈ [Audio] Source separation using Non-negative Matrix Factorization (NMF)

Notifications You must be signed in to change notification settings

97yong/source-separation-NMF

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎧 Source Separation with NMF

A simple and clean implementation of audio source separation using Non-negative Matrix Factorization (NMF). This project separates two sources from a mixed audio signal.


πŸ“ Project Structure

.
β”œβ”€β”€ main.py                     # Main script
β”œβ”€β”€ source_separation.py        # NMF dictionary & separation
β”œβ”€β”€ arguments.py                # CLI arguments
β”œβ”€β”€ data_loader.py              # Audio loading
β”œβ”€β”€ utils.py                    # Utilities (SDR, spectrograms)
β”œβ”€β”€ outputs/                    # Output results
└── data/
    β”œβ”€β”€ train/
    β”‚   β”œβ”€β”€ source_1.wav
    β”‚   └── source_2.wav
    └── test/
        └── test.wav

πŸš€ How to Run

pip install numpy librosa soundfile scikit-learn matplotlib
python main.py

βš™οΈ Command Line Options

Argument Description Default
--data_pathPath to dataset./data
--output_dirDirectory to save outputs./outputs
--srSampling rate48000
--n_componentsNMF components64
--n_fftFFT window size1024
--hop_lengthHop size for STFT512
--eval_sdrPrint SDR before/afterflag
--play_audioPlay result (IPython only)flag
--save_audioSave separated audioflag
--plot_spectrogramSave spectrogram imageflag

πŸ“Š Output

The script will save audio and a spectrogram image:

outputs/
β”œβ”€β”€ estimated_source_1.wav
β”œβ”€β”€ estimated_source_2.wav
└── spectrograms.png

Spectrogram Comparison


πŸ“š Reference

Lee, Daniel D., and H. Sebastian Seung.
"Learning the parts of objects by non-negative matrix factorization."
Nature 401.6755 (1999): 788–791.
πŸ”— DOI: 10.1038/44565

About

πŸŽ›οΈ [Audio] Source separation using Non-negative Matrix Factorization (NMF)

Topics

Resources

Stars

Watchers

Forks

Languages