--- 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 endpoint - `POST /upload` - Upload and analyze an audio file - `GET /recordings` - List all uploaded recordings - `GET /recordings/{filename}` - Download a specific recording - `GET /analyze/{filename}` - Analyze an existing recording - `DELETE /recordings/{filename}` - Delete a recording ## Supported Audio Formats - WAV - MP3 - OGG - FLAC ## File Size Limits Maximum file size: 10MB ## Usage Example ```python 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: 1. Install dependencies: `pip install -r requirements.txt` 2. Run the server: `python app.py` 3. Access the Swagger documentation at `http://localhost:7860/docs`