Leverage Singular Value Decomposition (SVD) for audio compression, aiming to efficiently reduce audio file sizes while maintaining high sound quality. This project uses the mathematical properties of SVD to achieve significant compression ratios without compromising audio integrity. It explores various levels of decomposition and reconstruction to find the optimal balance between compression ratio and audio fidelity.
The project converts audio signals into spectrograms, applies Singular Value Decomposition to compress the data, and reconstructs the audio from the compressed spectrogram. The steps include:
- Audio to Spectrogram: Transform the audio signal into its spectrogram representation using Short-Time Fourier Transform (STFT). This breaks down the audio into time-frequency components.
- Spectrogram to SVD: Decompose the spectrogram matrix using SVD, which separates it into singular vectors and values, allowing the reduction of dimensionality.
- SVD to Spectrogram: Truncate the singular values to compress the spectrogram data. The number of singular values retained determines the compression level and quality.
- Spectrogram to Audio: Reconstruct the audio signal from the compressed spectrogram using the Griffin-Lim algorithm.
In this project, an analysis of the memory space saved by using SVD for audio compression is also included. This involves comparing the original size of audio files to their compressed versions, taking into account various levels of singular value truncation. The analysis highlights the trade-off between compression ratio and audio quality, providing insights into the effectiveness of SVD in reducing storage requirements without significant loss of sound fidelity.
- Open the notebook on Google Colab.
- Upload the audio file you want to compress to the file section.
- Modify the filename in the code if you want to match your uploaded file.
- Install the requirements with
pip install -r requirements.txt
in your virtual environment. - Open the
SVD-AudioCompression.ipynb
notebook in your IDE. - Change the filename if you want to point to your audio file.
There is also a (worse performing) matlab version of the code
- Download the file in
matlab/SVD_AudioCompression.m
. - Install the add-on
Signal Processing Toolbox
. - Run with the song you want changing the filename at the beginning of the script.