File size: 1,738 Bytes
8b17c8d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31c7755
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
---
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`