Experiments/Visualizations

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 * 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.

Supported Formats

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

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

This provides you with the nice visualization

line

On this page