## Create a Task

detect_music.py

detectMusic.js

curl

```python
import requests

API_KEY = "your_api_key"
HEADERS = {"Content-Type": "application/json", "x-api-key": API_KEY}

response = requests.post(
    "https://api.audioshake.ai/tasks",
    headers=HEADERS,
    json={
        "assetId": "your_asset_id",
        "targets": [
            {"model": "music_detection", "formats": ["json"]}
        ]
    }
)

task_id = response.json()["id"]
print(f"Task created: {task_id}")
```

```javascript
const API_KEY = "your_api_key";
const headers = { "Content-Type": "application/json", "x-api-key": API_KEY };

const createRes = await fetch("https://api.audioshake.ai/tasks", {
  method: "POST",
  headers,
  body: JSON.stringify({
    assetId: "your_asset_id",
    targets: [
      { model: "music_detection", formats: ["json"] }
    ]
  })
});

const { id: taskId } = await createRes.json();
console.log(`Task created: ${taskId}`);
```

```bash
curl -X POST "https://api.audioshake.ai/tasks" \
  -H "Content-Type: application/json" \
  -H "x-api-key: $AUDIOSHAKE_API_KEY" \
  -d '{
    "assetId": "your_asset_id",
    "targets": [
      { "model": "music_detection", "formats": ["json"] }
    ]
  }'
```

## Output format

Music is detected in 10-second intervals. The output JSON contains an array of segments where music is present, each with a confidence score:

```json
[  
  {  
    "start_time": 20.0,  
    "end_time": 30.0,  
    "confidence": 0.18  
  },  
  {  
    "start_time": 40.0,  
    "end_time": 60.0,  
    "confidence": 0.32  
  }  
]
```

| Field         | Description                                          |
|---------------|------------------------------------------------------|
| `start_time` | Start of the music segment (seconds)                |
| `end_time`   | End of the music segment (seconds)                  |
| `confidence`  | Detection confidence score (0–1)                     |

## Use cases

- Flag content that requires music licensing review
- Build searchable timelines of music usage across archives
- Trigger stem separation or transcription only on segments containing music
- Monitor broadcast compliance with music usage policies
