AudioMagik is a comprehensive audio processing pipeline that demonstrates end-to-end audio analysis using deep learning models. It covers everything from loading and preprocessing audio files to visualizing spectrograms, tokenizing and transcribing audio using the HuBERT model, and discretizing token embeddings with K-Means clustering.
-
Audio Loading & Preprocessing:
Load local MP3 files using Hugging Face'sdatasetslibrary and preprocess them by resampling if necessary. -
Spectrogram Visualization:
Convert audio waveforms into mel spectrograms usingtorchaudio.transforms.MelSpectrogramand visualize them with Matplotlib. -
Tokenization & Transcription:
Leverage a pre-trained HuBERT model (facebook/hubert-large-ls960-ft) to tokenize and transcribe audio, with support for both CPU and GPU (including Apple's MPS). -
Discretization of Token Embeddings:
Apply a pre-trained K-Means clustering model to convert continuous token embeddings into discrete tokens. -
Runtime Timing:
Measure and print the total script runtime.
Ensure you have the necessary dependencies installed. You can install them using:
pip install -r requirements.txt-
Install Dependencies:
Run the command above to install all required packages. -
Run the Script:
Execute the main script with:python main.py
The script will:
- Load and preprocess an audio file.
- Visualize its spectrogram.
- Tokenize and transcribe the audio using the HuBERT model.
- Discretize the token embeddings with K-Means clustering.
- Print the total runtime of the script.
-
Device Support:
The script auto-detects available devices and prefers:- CUDA (if available)
- MPS (for Apple devices)
- CPU (fallback)
main.py: Main script containing the audio processing pipeline.requirements.txt: List of required Python packages.README.md: This documentation file.- Additional files may include model weights or clustering data if applicable.
This project is licensed under the MIT License.
- Hugging Face Transformers
- Torchaudio
- PyTorch
- Additional thanks to the open-source community for their contributions to these libraries.