For the complete documentation index, see llms.txt. This page is also available as Markdown.

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.

Image Labeling Toolbox: a blacksmith photo with the Audio tab listing two recordings, Hammer on anvil and Steel forging
A photo of a blacksmith with two recordings attached. The first one is playing.

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.

There is no way to attach audio from inside the labeling tool. Audio references are attached programmatically, at import time or afterwards, which is what this tutorial covers.

Supervisely Python SDK version 6.74.36 or newer is required, on a Supervisely instance running 6.17.25 or newer.

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:

Field
Required
What it is

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.

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:

Last updated

Was this helpful?