Skip to main content
Version: 21 Aug 2024

NativeBindings

See ml_voice.h for additional comments.

Inherits from:
MagicLeapNativeBindings

Public Methods

MLResult.Code MLVoiceIntentConfigureSettings

Sets the settings for voice intent events.

public MLResult.Code MLVoiceIntentConfigureSettings(
ulong handle,
in IntentSettings voiceSettings
)

Parameters

TypeNameDescription
ulonghandleHandle to the voice intent client.
in IntentSettingsvoiceSettingsPointer to MLVoiceIntentSettings structure.

Details*

App needs to call MLVoiceIntentConfigureSettings at least once before it calls MLVoiceIntentStartProcessing. App can call MLVoiceIntentConfigureSettings anytime it needs to update the voice intents. But such call will trigger updating intent grammar inside speech engine, which may result in a short delay (could be a few seconds depending on the device's workload). So it is not recommended to call the function frequently.

Returns: MLResult.Result will be MLResult.Code.InvalidParam if failed to set settings for voice intent events due to an invalid param. MLResult.Result will be MLResult.Code.Ok if Successfully set settings for voice intent events. MLResult.Result will be MLResult.Code.MLVoiceResult_IntentDisabled if failed to set the settings because required voice intent feature is disabled in system settings. MLResult.Result will be MLResult.Code.UnspecifiedFailure if the operation failed with an unspecified error.


MLResult.Code MLVoiceIntentCreate

Creates a voice intent client.

public MLResult.Code MLVoiceIntentCreate(
out ulong handle
)

Parameters

TypeNameDescription
out ulonghandleA handle to the created voice intent client. Only valid if the return value is MLResult.Code.Ok.

Returns: MLResult.Result will be MLResult.Code.InvalidParam if failed to create the voice intent client due to an invalid input parameter MLResult.Result will be MLResult.Code.Ok if successfully created the voice intent client. MLResult.Result will be MLResult.Code.PermissionDenied if failed to create client due to permission (permission).

Permissions: VOICE_INPUT


MLResult.Code MLVoiceIntentDestroy

Destroy a previously created voice intent client.

public MLResult.Code MLVoiceIntentDestroy(
ulong handle
)

Parameters

TypeNameDescription
ulonghandleHandle to the voice intent client.

Returns: MLResult.Result will be MLResult.Code.InvalidParam if failed to destroy the voice intent client due to an invalid input parameter MLResult.Result will be MLResult.Code.Ok if successfully destroyed the voice intent client.


MLResult.Code MLVoiceIntentIsEnabled

Checks voice intent feature is enabled in the system.

public MLResult.Code MLVoiceIntentIsEnabled(
ulong handle,
out bool isEnabled
)

Parameters

TypeNameDescription
ulonghandleHandle to the voice intent client.
out boolisEnabledResult whether voice intent feature is enabled.

Returns: MLResult.Result will be MLResult.Code.InvalidParam if failed to check due to an invalid parameter. MLResult.Result will be MLResult.Code.Ok if Successfully checked voice intent feature is enabled.


MLResult.Code MLVoiceIntentSetCallbacks

Sets the callbacks for voice intent events.

public MLResult.Code MLVoiceIntentSetCallbacks(
ulong handle,
in IntentCallbacks callbacks,
in IntPtr data
)

Parameters

TypeNameDescription
ulonghandleHandle to the voice intent client.
in IntentCallbackscallbacksPointer to MLVoiceIntentCallbacks structure. Set this to NULL to unregister callbacks.
in IntPtrdataPointer to user payload data (can be NULL).

Returns: MLResult.Result will be MLResult.Code.InvalidParam if failed to set callbacks for voice intent events due to an invalid param. MLResult.Result will be MLResult.Code.Ok if Successfully set callbacks for voice intent events. MLResult.Result will be MLResult.Code.MLVoiceResult_IntentDisabled if failed to set the callbacks because required voice intent feature is disabled in system settings. MLResult.Result will be MLResult.Code.UnspecifiedFailure if the operation failed with an unspecified error.


MLResult.Code MLVoiceIntentStartProcessing

Starts voice intent processing. This affects system voice service directly and permanently while system is running. Application should use this function carefully. It is strongly encourage to call MLVoiceIntentStopProcessing when the application is paused to avoid unexpected system behavior.

public MLResult.Code MLVoiceIntentStartProcessing(
ulong handle
)

Parameters

TypeNameDescription
ulonghandleHandle to the voice intent client.

Returns: MLResult.Result will be MLResult.Code.InvalidParam if failed to start processing due to an invalid parameter. MLResult.Result will be MLResult.Code.Ok if Successfully started intent processing. MLResult.Result will be MLResult.Code.UnspecifiedFailure if the operation failed with an unspecified error.


MLResult.Code MLVoiceIntentStopProcessing

Stops voice intent processing. This affects system voice service directly and permanently while system is running. Application should use this function carefully. It is strongly encourage to call this when the application is paused to avoid unexpected system behavior.

public MLResult.Code MLVoiceIntentStopProcessing(
ulong handle
)

Parameters

TypeNameDescription
ulonghandleHandle to the voice intent client.

Returns: MLResult.Result will be MLResult.Code.InvalidParam if failed to stop processing due to an invalid parameter. MLResult.Result will be MLResult.Code.Ok if Successfully stopped intent processing. MLResult.Result will be MLResult.Code.UnspecifiedFailure if the operation failed with an unspecified error.


delegate void OnVoiceEventDelegate

This callback will be invoked whenever a voice intent event is detected.

public delegate void OnVoiceEventDelegate(
in IntentEventInternal intentEvent,
IntPtr data
)

Parameters

TypeNameDescription
in IntentEventInternalintentEventVoice intent event.
IntPtrdataUser data as passed to MLVoiceIntentSetCallbacks().