This is a simple Flask web application for comparing audio files based on their MFCC (Mel-Frequency Cepstral Coefficients) features using cosine similarity. The application allows users to upload two audio files and set a similarity threshold. The server then compares the audio files and returns whether they are deemed similar or not based on the specified threshold.
Make sure you have Python installed on your system. You can install the required Python packages using the following command:
pip install flask librosa numpy scikit-learn
- Clone the repository:
git clone https://github.com/refaldyrk/compare_audio.git
cd compare_audio
- Run the Flask application:
python app.py
The application will be accessible at http://127.0.0.1:5000/
in your web browser.
- Parameters:
base_audio
: The base audio file (required).input_audio
: The input audio file (required).
- Response:
- JSON object with the result of the comparison.
{
"result": "similar" or "not similar"
}
import requests
import os
url = "http://127.0.0.1:5000/compare_audio"
files = {
"base_audio": open("path/to/base_audio.wav", "rb"),
"input_audio": open("path/to/input_audio.wav", "rb"),
}
response = requests.post(url, files=files)
result = response.json()
print(f"The audio files are {result['result']}.")