This project is a web application built with FastAPI that allows users to upload audio files (WAV format) and decompose them into their Fourier components. The application performs a Fast Fourier Transform (FFT) on the audio signal and identifies the dominant frequencies.
- File Upload: Allows users to upload WAV files for processing.
- Fourier Analysis: Computes the Fourier Transform of the audio signal and returns the dominant frequencies.
- Visualization: (Optional) Could be extended for plotting or visualizing the frequency spectrum.
- FastAPI: For creating the web application.
- librosa: For loading and reading audio files.
- NumPy: For performing the FFT and manipulating the signal.
- Jinja2: For rendering HTML templates.
- Python 3.7+
- A virtual environment (optional but recommended)
-
Clone the repository:
git clone https://github.com/susmita2022khatun/Fourier_decomposition.git cd Fourier_decomposition
-
Create and activate a virtual environment (optional):
python -m venv venv # On Windows venv\Scripts�ctivate # On Mac/Linux source venv/bin/activate
-
Install the required dependencies:
pip install -r requirements.txt
-
Ensure the
uploads
andstatic
directories exist:uploads/
will store the uploaded audio files.static/
will contain static files (CSS, JS, etc.).
-
Run the application:
python main.py
The application will start the server at
http://127.0.0.1:8000/
.
- Visit the application in a browser at
http://127.0.0.1:8000/
. - Upload a WAV file using the file input on the webpage.
- The server will process the audio and return a JSON response containing the dominant frequencies in the audio signal.
{
"filename": "example.wav",
"dominant_frequencies": [440.0, 880.0, 1320.0]
}
main.py
: Contains the FastAPI application logic, including routes for uploading files and processing them using the FFT.process.py
: Contains helper functions for performing Fourier decomposition, includingdiscrete_fourier
,fft
, andfftfreq
.static/
: Directory for static files like CSS or JavaScript (optional, could be used for front-end enhancements).templates/
: Contains HTML templates (likeindex.html
) rendered by FastAPI using Jinja2.