This project provides a FastAPI backend and a React frontend for processing audio files. Initially focused on denoising, it's being expanded to include more audio manipulation features.
- Audio Denoising: Upload an audio file (WAV, MP3, FLAC) to remove background noise.
- Adjustable Denoising Strength: Ranges from
0.0(no effect) to1.0(maximum effect).
- Adjustable Denoising Strength: Ranges from
- Audio Equalization: Apply multi-band parametric equalization. Each band has center frequency, gain (dB), and Q-factor.
- Audio Normalization: Normalize audio loudness to a target level (EBU R128, typically -23 LUFS).
- Format Conversion: Convert processed audio to WAV, MP3, or FLAC.
- Waveform Data Generation: Optionally retrieve waveform data (amplitude peaks) for the original and processed audio, suitable for visualization.
The backend is built with FastAPI.
- Endpoint:
POST /process/ - Description: Accepts an audio file and processing parameters, then returns the processed audio. If
request_waveformis true, returns a JSON response containing the audio as base64, along with waveform data. - Request Body:
multipart/form-datafile: The audio file (types:audio/wav,audio/mpeg,audio/flac).denoise_strength(optional, float, default:0.5): Controls the denoising aggressiveness. Ranges from0.0(no effect) to1.0(maximum effect).output_format(optional, string, default:wav): Desired output audio format. Supported:wav,mp3,flac.eq_bands_json(optional, string, default:null): JSON string representing an array of EQ bands. Each band is an object:{"freq": <number>, "gain": <number>, "q": <number>}. Example:'[{"freq": 100, "gain": -3, "q": 0.7}, {"freq": 1000, "gain": 2, "q": 1.4}]'apply_normalization(optional, boolean, default:False): If true, applies loudness normalization to the audio.request_waveform(optional, boolean, default:False): If true, the response will be JSON containing base64 encoded audio and waveform data. Otherwise, the response is a direct audio file stream.
- Response:
- If
request_waveformisFalse(default):- Success (200 OK): The processed audio file as a stream, with
Content-Typeset to the appropriate audio format andContent-Dispositionsuggesting a filename likeprocessed_{original_filename}.{output_format}.
- Success (200 OK): The processed audio file as a stream, with
- If
request_waveformisTrue:- Success (200 OK): A JSON object with the following structure:
{ "message": "Audio processed successfully.", "audio_filename": "processed_original.wav", "audio_format": "wav", "audio_b64": "<base64_encoded_audio_string>", "original_waveform": [<float_values>...], "processed_waveform": [<float_values>...], "denoise_strength_applied": 0.5, "eq_bands_applied": [{"freq": 100, "gain": -3, "q": 0.7}], // or null "normalization_applied": true }
- Success (200 OK): A JSON object with the following structure:
- Error (400 Bad Request): If parameters are invalid (e.g., unsupported format, invalid strength, malformed
eq_bands_json). - Error (422 Unprocessable Entity): If the
fileis missing or of an invalid type for FastAPI'sUploadFile.
- If
1. Simple Denoising and Format Conversion (File Output):
curl -X POST -F "file=@/path/to/your/audio.wav" \
-F "denoise_strength=0.7" \
-F "output_format=mp3" \
http://localhost:8000/process/ -o processed_audio.mp32. Complex Processing with EQ, Normalization, and Waveform Data (JSON Output):
curl -X POST \
-F "file=@/path/to/your/audio.flac" \
-F "denoise_strength=0.3" \
-F "output_format=wav" \
-F "eq_bands_json='[{\"freq\": 80, \"gain\": 2.5, \"q\": 0.7}, {\"freq\": 1000, \"gain\": -1.5, \"q\": 1.2}]'" \
-F "apply_normalization=True" \
-F "request_waveform=True" \
http://localhost:8000/process/ -o response.json
# The output 'response.json' will contain the base64 audio and waveform data.The frontend is a React application allowing users to:
- Upload an audio file.
- Adjust the denoising strength using a slider.
- Select the desired output audio format.
- Process the audio.
- Play back the processed audio.
- Download the processed audio.
This section guides you through setting up and running the project locally.
- Python: Version 3.9 or newer.
- Node.js: Version 14.x or newer (which includes npm).
- pip: Python package installer (usually comes with Python).
- npm: Node package manager (usually comes with Node.js).
- Navigate to the backend directory:
cd backend - Create a virtual environment (recommended):
python -m venv venv
- Activate the virtual environment:
- On macOS and Linux:
source venv/bin/activate - On Windows:
.\venv\Scripts\activate
- On macOS and Linux:
- Install Python dependencies:
pip install -r requirements.txt
- Run the FastAPI development server:
The backend API will typically be available at
uvicorn fastapi_main:app --reload
http://localhost:8000.
-
Navigate to the frontend React app directory:
cd frontend/react-app(If you are already in the
backenddirectory from the previous step, you might usecd ../frontend/react-app) -
Install Node.js dependencies:
npm install
-
Start the React development server:
npm start
The frontend application will typically be available at
http://localhost:3000. It's configured to proxy API requests to the backend athttp://localhost:8000.
- Audio Equalizer: Add a multi-band equalizer.
- Audio Normalization: Adjust audio to a standard peak or average loudness.
- Waveform Visualization: Display waveforms before and after processing. We will try Using Fast API and other API with Python