metadata
title: Audio Emotion Detection API
emoji: 🎵
colorFrom: blue
colorTo: purple
sdk: docker
sdk_version: latest
app_file: app.py
pinned: false
Audio Emotion Detection API
This application provides an API for detecting emotions in audio files using the wav2vec2 model fine-tuned for emotion recognition.
Features
- Upload audio files for emotion analysis
- List all uploaded recordings
- Download previously uploaded recordings
- Analyze existing recordings
- Delete recordings
API Endpoints
GET /health
- Health check endpointPOST /upload
- Upload and analyze an audio fileGET /recordings
- List all uploaded recordingsGET /recordings/{filename}
- Download a specific recordingGET /analyze/{filename}
- Analyze an existing recordingDELETE /recordings/{filename}
- Delete a recording
Supported Audio Formats
- WAV
- MP3
- OGG
- FLAC
File Size Limits
Maximum file size: 10MB
Usage Example
import requests
# Upload and analyze an audio file
with open('your_audio.wav', 'rb') as f:
files = {'file': f}
response = requests.post('https://your-space-url.hf.space/upload', files=files)
print(response.json())
Technical Details
- Based on FastAPI
- Uses Hugging Face's wav2vec2-base-superb-er model for emotion recognition
- Optimized for Hugging Face Spaces deployment
- Automatic file cleanup to manage storage limits
Storage Management
Files are automatically cleaned up after 24 hours to manage storage limits on Hugging Face Spaces.
Development
To run this API locally:
- Install dependencies:
pip install -r requirements.txt
- Run the server:
python app.py
- Access the Swagger documentation at
http://localhost:7860/docs