Audio references on images
Introduction
You can attach one or more audio files to an image as references: the sound of the machine in the photo, an animal call recorded where the picture was taken, or a voice note from whoever took it. When the image is opened in the Image Labeling Toolbox, its recordings are listed in the Audio tab of the right sidebar, each with its own player, so the annotator can listen while labeling.

Photo: Blacksmith forging a candlestick.jpg by Jacek Rużyczka, CC BY-SA 4.0. Audio: Work With Sounds (La Fonderie; Museum of Municipal Engineering), CC BY 4.0. All via Wikimedia Commons.
Audio references are reference only. They are never annotated: they carry no figures, no tags and no geometry, and they are not part of the annotation.
The audio file itself is not stored inside the project — only its URL is. The file has to live somewhere the instance can serve it, and Team Files is the usual place.
Prerequisites
Step 1. Prepare ~/supervisely.env file with credentials. Learn more here.
Step 2. Install the SDK.
Step 3. Initialize the API client.
How audio references are stored
References live in the image's meta field, under the audio key, as a list of objects:
url
yes
Direct URL of the audio file.
name
no
Label shown next to the player.
mimeType
no
MIME type, e.g. audio/mpeg.
This is the only shape the SDK reads and writes. sly.AudioReference is the typed form of one entry, so you do not have to build these dictionaries by hand:
Upload a local audio file and attach it
upload_audio_reference does both steps at once: it uploads the file to Team Files and attaches the resulting URL to the image.
By default the file lands in /audio-references/<image id>/<file name>, and name defaults to the file name without its extension. Pass remote_path to choose a different location in Team Files.
Open the image in the Image Labeling Toolbox and the recording appears under the Audio tab of the right sidebar, labelled with name.
The project keeps only the URL, so the file has to stay in Team Files. Delete it and the player stops working.
Attach a file that is already hosted
If the audio is already reachable by URL, attach it directly.
set_audio_references replaces the whole list; other keys in the image meta are left alone:
add_audio_reference appends to what is already attached:
Pass an empty list to remove every reference:
Read them back
Entries that are not in the canonical form — anything without a url — are skipped with a warning instead of raising, so one hand-written entry cannot make the whole image unreadable.
Attach audio while uploading images
When you upload an image you pass meta rather than an image ID. update_audio_references returns a copy of a meta dict with the references written into it:
Import and export
Audio references travel with the project as part of the image metadata, so you have to ask for image metadata explicitly. save_image_meta defaults to False:
This writes one JSON file per image under <dataset>/meta/, which upload_project reads back:
Only the URLs are exported, not the audio files. Importing into a different instance leaves references pointing at the instance they came from — reachable only while that instance serves them. To make a copy self-contained, re-upload the audio with upload_audio_reference after the import.
Last updated
Was this helpful?