Creating an Audio Clip
This tutorial walks through the process of creating and publishing an audio clip using the Arc XP Audio API.
1. Create an Empty Record
First, create a metadata record for your audio clip. This establishes the clip in the system before you upload the actual audio file.
curl -X POST https://api.[org].arcpublishing.com/audiocenter/api/editorial/v1/clips/ \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "title": "Tutorial Audio Clip", "description": "A sample audio clip created via API", "tags": ["tutorial"] }'The API returns a 201 Created response, which includes the ID of the new audio clip. The Location header in the response contains the URL of the new resource.
2. Upload Audio
Once you have the audio_id, you can upload your audio file (WAV or MP3).
curl -X POST https://api.[org].arcpublishing.com/audiocenter/api/editorial/v1/clips/{audio_id}/upload \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -F "file=@/path/to/your/audio.mp3"Monitoring Progress with SSE
Audio processing happens asynchronously. To monitor this process in real-time, include the Accept: text/event-stream header in your upload request:
curl -X POST https://api.[org].arcpublishing.com/audiocenter/api/editorial/v1/clips/{audio_id}/upload \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -H "Accept: text/event-stream" \ -F "file=@/path/to/your/audio.mp3"When this header is present, the API returns a Server-Sent Events (SSE) stream that provides updates on the processing state:
CREATED: Record exists, waiting for upload.PROCESSING: File received, and is processing.READY: Processing complete; the clip is ready to be published.FAILED: An error occurred during processing.
3. Publish the Clip
To make the audio clip available on the public internet, it needs to be published.
After the processing state reaches READY, you can publish the clip to make it available for delivery.
curl -X POST https://api.[org].arcpublishing.com/audiocenter/api/editorial/v1/clips/{audio_id}/publish \ -H "Authorization: Bearer YOUR_API_TOKEN"Once published, the clip’s publishing_status will transition to PUBLISHED.
4. Use with the Audio Player
Provide the audio_id to the audio player to view the clip.
<script type="module" src="https://[org]-[environment].audio.arc-cdn.net/player/koi/v0.2.17/koi-player.min.js"></script>
<h1>Hello Audio!</h1><koi-audio-player media-id="{AUDIO_ID}" org-id="{ORG_ID}"></koi-audio-player>