Skip to main content
Audio clipping identifies when something can be heard. Ask for the onset of a sound, the duration of an audible event, or the interval containing a spoken phrase. The response contains <clip> annotations in text. Use their timestamps for playback or editing in your application; the API does not return a cut audio file.

Locate an audible event

Install perceptron>=0.4.0, set PERCEPTRON_API_KEY, and place a short WAV recording at ./recording.wav. This example asks for the first alarm in your recording. If there is no clear alarm, the prompt asks the model to report that instead of inventing an interval.
vision_config.annotation_format: "clip" requests temporal annotations for audio as well as video. Standalone audio does not require enable_audio_in_video. For MP3, FLAC, remote URLs, or uploaded files, use the corresponding audio input form.

Ask for a moment or an interval

Reuse locate_event to ask for a single boundary instead of a duration:
These annotations illustrate the two formats; they are not measured predictions for your recording:
A single timestamp is a moment. Two timestamps give the start and end of an interval. For repeated events, ask for a separate interval for each occurrence. A collection can group those intervals under a shared description and asset selector; see annotation format. Define the boundary you need in the prompt: Use audio transcription when you need the spoken words, or audio Q&A when you need an explanation of their meaning.

Keep timestamps attached to the recording

Times are measured in seconds from the start of the supplied recording. If you create an excerpt starting 120 seconds into a longer recording, a returned time of 2.4 seconds maps to 122.4 seconds in the original. Keep that offset with the excerpt when combining results. asset_idx="0" selects the recording in this example. The attribute is optional, even when requested: without an explicit or inherited selector, use the last asset available when the annotation was produced. With several recordings or other media, resolve the asset selector before interpreting times.

Validate before seeking or cutting

  • Require a completed response. A length finish reason or interrupted stream can leave an unfinished annotation.
  • Check that times are finite, nonnegative, within the selected recording, and ordered for an interval. A moment needs an application-chosen interval before it can become a playable excerpt.
  • Listen around the proposed boundary before making a precise cut. Requested tags and timestamps are model output to validate, not a guarantee of sample-accurate alignment.
Long recordings share the model’s input and output budget. See audio limits before sending a recording. For audible events in a video, use video clipping with sound and explicitly enable soundtrack processing.