NatML
Search…
MLAudioFeature
class NatSuite.ML.Features.MLAudioFeature : MLFeature, IMLFeature
This feature contains raw audio data. Currently, NatML only supports floating-point linear PCM audio data.

Creating the Feature

The audio feature can be created from several different audio inputs:

From an AudioClip

1
/// <summary>
2
/// Create an audio feature from an audio clip.
3
/// </summary>
4
/// <param name="clip">Audio clip.</param>
5
/// <param name="duration">Optional duration to extract in seconds.</param>
6
MLAudioFeature (AudioClip clip, float duration = ...);
Copied!
The audio feature can be created from an AudioClip, with the optional ability to specify the duration of the clip to extract.

From a Buffer List

1
/// <summary>
2
/// Create an audio feature from a sample buffer list.
3
/// </summary>
4
/// <param name="sampleBuffer">List of linear PCM sample buffers.</param>
5
/// <param name="sampleRate">Sample rate.</param>
6
/// <param name="channelCount">Channel count.</param>
7
MLAudioFeature (IEnumerable<float[]> bufferList, int sampleRate, int channelCount);
Copied!
The audio feature can be created from an audio buffer list. This is useful for audio-based predictors that make predictions on longer segments of audio data, like speech-to-text models.

From a Sample Buffer

1
/// <summary>
2
/// Create an audio feature from a sample buffer.
3
/// </summary>
4
/// <param name="sampleBuffer">Linear PCM sample buffer.</param>
5
/// <param name="sampleRate">Sample rate.</param>
6
/// <param name="channelCount">Channel count.</param>
7
MLAudioFeature (float[] sampleBuffer, int sampleRate, int channelCount)
Copied!
The audio feature can also be created from a single sample buffer. This constructor has a corresponding variant which accepts a raw sample buffer in native memory:
1
/// <summary>
2
/// Create an audio feature from a sample buffer.
3
/// </summary>
4
/// <param name="sampleBuffer">Linear PCM sample buffer.</param>
5
/// <param name="sampleCount">Total sample count.</param>
6
/// <param name="sampleRate">Sample rate.</param>
7
/// <param name="channelCount">Channel count.</param>
8
MLAudioFeature (float* sampleBuffer, int sampleCount, int sampleRate, int channelCount);
Copied!

Inspecting the Feature

1
/// <summary>
2
/// Feature type.
3
/// </summary>
4
MLFeatureType type { get; }
Copied!
Refer to the Inspecting the Feature section of the MLFeature class for more information.
The type is always an MLAudioType .
Last modified 4mo ago