Audio

Visualize your audio

mlop supports logging audio types to the platform, you can upload an audio using its file path or a NumPy array containing audio data forming frames x channel.

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,
)

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.

Then log the audio as standard

mlop.log({"audio/0": audio})

This provides you with the visualization as such

line

:::tip mlop uses soundfile as its backend for audio logging, with the following supported formats. :::

Examples

File Path

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")})

NumPy Array

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

On this page