Skip to main content
Audio files are supported on the platform, and can be uploaded via a file path or a Numpy array containing audio data forming frames * channels
You can instantiate an audio object using the mlop.Audio constructor.
audio = mlop.Audio(
    data=Union[str, np.ndarray],
    rate=int | None = 48000,
    caption=str | None = None,
)
mlop.log({"audio/0": audio})
ParameterTypeDescription
dataUnion[str, np.ndarray]The audio data to log. Can be a path to an audio file or a NumPy array.
rateintThe sample rate of the audio data. Defaults to 48000.
captionstrA caption for the audio.

Examples

Logging from File Paths

import httpx
r = httpx.get(
    "https://actions.google.com/sounds/v1/alarms/digital_watch_alarm_long.ogg"
)
with open(f"test.ogg", "wb") as f:
    f.write(r.content)
 
mlop.log({"audio": mlop.Audio(data="test.ogg")})

Logging from NumPy Arrays

data = np.array([1, 1, 1], [1, 1, 1], dtype=np.float32)
mlop.log({"audio": mlop.Audio(data=data)})