File size: 3,453 Bytes
f280f9f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# Madverse Music: AI Audio Classifier - Usage Guide

## Quick Start

### Option 1: Hugging Face Space (Recommended)
Use our deployed model on Hugging Face Spaces:

**Web Interface:**
1. Go to the Hugging Face Space URL
2. Upload your audio file
3. Click "Analyze Audio"
4. Get instant results

**API Access:**
```bash

# Health check

curl https://your-space-name.hf.space/health



# Analyze audio file

curl -X POST "https://your-space-name.hf.space/analyze" \

     -F "[email protected]"

```

### Option 2: Local Setup
```bash

# Install dependencies

pip install -r requirements.txt



# Start the API server

python api.py



# Or start web interface

streamlit run app.py

```

## Supported Audio Formats
- WAV (.wav)
- MP3 (.mp3) 
- FLAC (.flac)
- M4A (.m4a)
- OGG (.ogg)

## API Usage

### Hugging Face Space API

#### Health Check
```bash

GET /health

```

#### Analyze Audio
```bash

POST /analyze

```
Upload audio file using multipart/form-data

**Request:**
Upload file using form data with field name "file"

**Response Format:**
```json

{

  "classification": "Real",

  "confidence": 0.85,

  "probability": 0.15,

  "raw_score": -1.73,

  "duration": 30.5,

  "message": "Detected as real music"

}

```



### Usage Examples

#### Python
```python

import requests



# Upload file to HF Space

with open('your_song.mp3', 'rb') as f:

    response = requests.post('https://your-space-name.hf.space/analyze', 

                           files={'file': f})

result = response.json()

print(result)

```

#### JavaScript
```javascript

const formData = new FormData();

formData.append('file', fileInput.files[0]);



const response = await fetch('https://your-space-name.hf.space/analyze', {

    method: 'POST',

    body: formData

});

const result = await response.json();

```

## Understanding Results

The classifier will output:
- **"Real"** = Human-created music
- **"Fake"** = AI-generated music (from Suno, Udio, etc.)

### API Response Format:
```json

{

  "classification": "Real",

  "confidence": 0.85,

  "probability": 0.15,

  "raw_score": -1.73,

  "duration": 30.5,

  "message": "Detected as real music"

}

```

### Command Line Output:
```

Analyzing: my_song.wav

Result: Fake (AI-generated music)

Confidence: 0.96 | Raw output: 3.786

```

## Model Specifications
- Model: SpecTTTra-α (120 seconds)
- Sample Rate: 16kHz
- Performance: 97% F1 score, 96% sensitivity, 99% specificity
- Max Duration: 120 seconds (2 minutes)

## Technical Details

### How It Works:
1. Audio is loaded and resampled to 16kHz
2. Converted to mel-spectrograms
3. Processed by the SpecTTTra transformer model
4. Output logit is converted to probability using sigmoid
5. Classification: `prob < 0.5` = Real, `prob ≥ 0.5` = Fake

### Testing Your Music

1. Get AI-generated samples: Download from Suno, Udio, or other AI music platforms
2. Get real music samples: Use traditional human-created songs
3. Run the classifier: Compare results to see how well it detects AI vs human music

## Expected Performance
- High accuracy on detecting modern AI-generated music
- Works best with full songs (up to 120 seconds)
- Optimized for music from platforms like Suno and Udio

Note: This model was trained specifically for detecting AI-generated songs, not just AI vocals over real instrumentals. It analyzes the entire musical composition.