Here's a brief description of the project's main components and functionalities:
-
Libraries and Imports: The project starts by importing necessary Python libraries, including NumPy, Librosa, IPython, Matplotlib, and SciPy, to handle audio processing, visualization, and signal manipulation.
-
Loading Audio: An audio file named "intro4.wav" is loaded using Librosa. It's displayed using IPython's Audio widget, allowing you to listen to the original audio.
-
Plotting Magnitude Spectrum: The script defines a function called
plot_magnitude_spectrum
that calculates and plots the magnitude spectrum of the input audio signal. This function is then applied to the loaded audio to visualize its frequency components. -
Generating Band-Limited Noise: The project generates band-limited noise and adds it to the audio signal to simulate background noise. The noise is created within a specific frequency range (between 4,000 Hz and 12,000 Hz) and added to the audio clip.
-
Fourier Transform Analysis: The Fourier transform of the noisy audio signal is computed, and the magnitude of the Fourier coefficients is plotted to visualize the frequency domain characteristics.
-
Noise Reduction: The core of the project is the
removeNoise
function, which performs noise reduction on the audio clip. It does the following:- Separates the noise and signal components using Short-Time Fourier Transform (STFT).
- Calculates statistics on the noise and determines a threshold for noise removal.
- Applies a mask to the signal based on the calculated threshold.
- Smooths the mask using a filter.
- Applies the mask to the noisy signal in the frequency domain.
- Recovers the cleaned signal through inverse STFT.
-
Visualization: The script includes various visualization functions to display the noisy audio, statistics of the noise, the mask applied to the signal, the masked signal, and the recovered spectrogram.
-
Output and Playback: After noise reduction, the cleaned audio signal is plotted and played back using IPython's Audio widget.
In summary, this project aims to demonstrate the process of removing noise from an audio clip using signal processing techniques and visualization tools. It utilizes the Librosa library for audio processing and provides visual feedback at various stages of the noise reduction process.