AudioAsset

class VideoKit.Assets.AudioAsset : MediaAsset

An AudioAsset refers to an encoded audio file.

Creating an Audio Asset

Audio assets can be created from files or audio clips using the MediaAsset factory methods.

From a File

// Create an audio asset from a file
string path = "/path/to/audio.wav";
AudioAsset audioAsset = await MediaAsset.FromFile(path) as AudioAsset;

An audio asset can be created using the MediaAsset.FromFile method. The path should point to any encoded audio file.

From an Audio Clip

// Create an audio asset from an audio clip
AudioClip clip = ...;
AudioAsset audioAsset = await MediaAsset.FromAudioClip(clip);

An audio asset can be created using the MediaAsset.FromAudioClip method.

Inspecting the Audio Format

The AudioAsset reports the audio format of the audio file it refers to:

Audio Sample Rate

/// <summary>
/// Audio sample rate.
/// </summary>
int sampleRate { get; }

The AudioAsset reports the audio sampleRate is specified in Hertz.

Audio Channel Count

/// <summary>
/// Audio channel count.
/// </summary>
int channelCount { get; }

The AudioAsset reports the number of channels in the audio file.

Audio Duration

/// <summary>
/// Audio duration in seconds.
/// </summary>
float duration { get; }

The AudioAsset reports the duration of the audio file in seconds.

Generating Audio Captions

/// <summary>
/// Generate captions for the audio asset.
/// NOTE: This requires an active VideoKit AI plan.
/// </summary>
Task<string> Caption ();

The AudioAsset can generate captions of the audio file, allowing you to do things like speech-to-text.

This requires an active VideoKit AI plan.

Last updated