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:

  1. Music Generation

    • Uses a pre-trained model (e.g., MusicGen) to produce audio from text.
  2. Audio Degradation

    • Downsamples and alters generated audio to simulate poor fidelity.
  3. U-Net Restoration

    • Enhances low-quality waveform using an encoder-decoder network.
  4. CNN Evaluation

    • Predicts perceptual quality of restored audio using spectrograms.
  5. 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

MethodCQSMOS
MusicGen (baseline)0.9910.871
U-Net Enhanced0.9980.893
MethodSNRLSD
U-Net Enhanced4.7570.246

Authors

-- πŸ“š This project was developed as part of an academic course at Sapienza UniversitΓ  di Roma.