HOW TO RUN IT
July 9, 2025 Β· View on GitHub
Firstly, install the conda env provided by the environment.yaml file. To run correctly the code, we have to consider 4 main files:
π audio-restore/
βββ π quality_estimator_code/
β βββ π python/
β βββ estimate_quality.py
βββ π restore_code/
β βββ π python/
β βββ start.py
βββ music_gen.py
βββ text_to_music_eval_prompts.csv
On the csv file, you can add all the prompts from which you want to generate music, then run music_gen.py.
In start.py you have to pay attention on 2 constants:
- INPUT_FILE: music_gen generated audio path
- OUTPUT_FIN: restored audio path
So write correctly these 2 paths.
Then you only have to execute the following command:
python -m quality_estimator_code.python.estimate_quality
It will try to restore the INPUT_FILE and then it will estimate a quality score.
π§ Audio Restoration for Generative Models
This repository implements a modular enhancement pipeline designed to improve the perceptual quality of audio generated by text-to-music models such as MusicGen. While these models are capable of generating coherent musical ideas from text prompts, their outputs often suffer from compression artifacts, low bit depth, and a lack of high-frequency fidelity. Our pipeline addresses this gap by introducing a U-Net-based restoration module and a CNN-based perceptual quality estimator.
π§ Abstract
Recent generative audio models like MusicGen produce impressive musical samples directly from text. However, these generations often suffer from low bit depth, quantization artifacts, noise, and a general lack of high-fidelity detail compared to studio-quality audio.
In this project, we propose a novel approach to enhance the perceptual quality of generated audio. We employ a U-Net architecture to perform post-processing on the audio, removing artifacts and restoring acoustic richness. Additionally, we introduce a CNN-based quality assessment module trained to predict perceptual audio quality. This module provides feedback that guides the U-Net during training. Our results show measurable improvements both in objective metrics and subjective listening tests.
ποΈ Repository Structure
π audio-restore/
βββ π restore_code/
β βββ π Jupyter/
β β βββ convert_wav_audio.ipynb # Converts MP3 to mono WAV
β β βββ downsample_song.ipynb # Simulates degradation (downsampling, noise)
β β βββ audio_restore_train.ipynb # Trains U-Net on degraded/clean waveform pairs
β βββ π python/
β βββ start.py # Restore audio quality
βββ π quality_estimator_code/
β βββ π Jupyter/
β β βββ Discriminator.ipynb # Trains CNN quality predictor on spectrograms
β βββ π python/
β βββ estimate_quality.py # Launches the full pipeline
βββ music_gen.py # Wraps MusicGen inference from prompts
βββ π data/
β βββ π train/ # Example dataset (Free Music Archive subset)
βββ π models/ # Saved weights for U-Net and CNN
π© Installation
Install dependencies with:
conda env create -f environment.yaml
π» System Overview
The pipeline consists of the following components:
-
Music Generation
- Uses a pre-trained model (e.g., MusicGen) to produce audio from text.
-
Audio Degradation
- Downsamples and alters generated audio to simulate poor fidelity.
-
U-Net Restoration
- Enhances low-quality waveform using an encoder-decoder network.
-
CNN Evaluation
- Predicts perceptual quality of restored audio using spectrograms.
-
Loss Functions
- Combined L1 loss and CNN-based perceptual loss guide training.
Experimental Setup
- Dataset: MusicGen outputs (10s, 32kHz)
- Degraded: Downsampled to 8kHz, then restored
- Train/Val split: 80/20
- Optimizer: Adam
- Epochs: 80
- Learning Rate: 5e-5
π Evaluation Metrics
- SNR (Signal-to-Noise Ratio): measures denoising
- LSD (Log Spectral Distance): frequency-domain fidelity
- CQS (CNN Quality Score): learned perceptual score
- MOS (Mean Opinion Score): subjective test on 10 participants
Results
| Method | CQS | MOS |
|---|---|---|
| MusicGen (baseline) | 0.991 | 0.871 |
| U-Net Enhanced | 0.998 | 0.893 |
| Method | SNR | LSD |
|---|---|---|
| U-Net Enhanced | 4.757 | 0.246 |
Authors
- Paul Alexandru Radu Loghin (raduloghin.1942544@di.uniroma1.it)
- Andrea Maggiore (maggiore.1947898@di.uniroma1.it)
-- π This project was developed as part of an academic course at Sapienza UniversitΓ di Roma.