MLVoice
NameSpace: MagicLeap
APIs for the voice service system. More...
Inherits from:
MLAutoAPISingleton< MLVoice >,
MLLazySingleton< T >
Detailed Description
public class MLVoice : MLAutoAPISingleton< MLVoice >
Details*
APIs for the voice service system.
To use the voice feature (with a specific application's intent list), the application should send a Scriptable Object called MLVoiceIntentsConfiguration, Located under Assets/Magic Leap/Voice Intents Configuration, with the application's voice intents data to MLVoice.SetupVoiceIntents().
Name, id, and value should be unique. Value is the phrase needed to be spoken out loud after "Hey Magic Leap" " | " may be used in the configuration file's value field to indicate multiple values tied to the same name and id.
Public Fields
OnVoiceEvent
Event invoked for when a data channel opens.
public static OnVoiceEventDelegate OnVoiceEvent { get; set; }
Type | Description |
---|---|
OnVoiceEventDelegate | This callback will be invoked whenever a voice intent event is detected. |
Public Methods
delegate void OnVoiceEventDelegate
This callback will be invoked whenever a voice intent event is detected.
public delegate void OnVoiceEventDelegate(
in bool wasSuccessful,
in IntentEvent voiceEvent
)
Parameters
Type | Name | Description |
---|---|---|
in bool | wasSuccessful | Voice event handling result. In case of false, voiceEvent member variables should be ignored. (voiceEvent.EventName will be NULL) |
in IntentEvent | voiceEvent | Voice intent event. |
Details*
///
MLResult SetupVoiceIntents
Configures Settings sent, Sets the callbacks for voice intent events, and starts processing.
public static MLResult SetupVoiceIntents(
MLVoiceIntentsConfiguration voiceConfiguration
)
Parameters
Type | Name | Description |
---|---|---|
MLVoiceIntentsConfiguration | voiceConfiguration | MLVoiceIntentsConfiguration scriptable object that contains the App Intents data. Memory of this variable is managed by user. |
Details*
Max Voice Intents Supported: 100
Returns: MLResult.Result will be MLResult.Code.InvalidParam if failed due to an invalid param. MLResult.Result will be MLResult.Code.Ok if Successfully set settings, callbacks, and starts processing. MLResult.Result will be MLResult.Code.MLVoiceResult_IntentDisabled if failed to set the callbacks or 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 SetupVoiceIntents
Configures Settings sent, Sets the callbacks for voice intent events, and starts processing.
public static MLResult SetupVoiceIntents(
string JSONString
)
Parameters
Type | Name | Description |
---|---|---|
string | JSONString | The JSON file with the voice intents data in the proper format. |
Details*
When providing a string instead of the MLVoiceIntentsConfiguration Scriptable Object no validation is done to confirm proper format.
Max Voice Intents Supported: 100
Returns: MLResult.Result will be MLResult.Code.InvalidParam if failed due to an invalid param. MLResult.Result will be MLResult.Code.Ok if Successfully set settings, callbacks, and starts processing. MLResult.Result will be MLResult.Code.MLVoiceResult_IntentDisabled if failed to set the callbacks or 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 Stop
Stop unsets callbacks and stops processing. This is not necessary for shutdown. This is only needed if a user wants to stop processing at runtime after call MLVoice.SetupVoiceIntents. MLVoice can be restarted by calling MLVoice.SetupVoiceIntents.
public static MLResult Stop()
Returns: MLResult.Result will be MLResult.Code.InvalidParam if failed due to an invalid param. MLResult.Result will be MLResult.Code.Ok if Successfully unset callbacks and stops processing. MLResult.Result will be MLResult.Code.MLVoiceResult_IntentDisabled if failed 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.
Protected Methods
OnApplicationPause
Callback sent to all MagicLeap APIs on application pause.
protected virtual override void OnApplicationPause(
bool pauseStatus
)
Parameters
Type | Name | Description |
---|---|---|
bool | pauseStatus | True if the application is paused, else False. |
Reimplements: OnApplicationPause
StartAPI
Do API-specific creation/initialization of ML resources for this API, such as creating trackers, etc. Called automatically the first time Instance is accessed. Error checking on the return value is performed in the base class.
protected virtual override MLResult.Code StartAPI()
Reimplements: StartAPI
StopAPI
API-specific cleanup. Will be called whenever MLDevice is destroyed (at the latest, when the application is shutting down). Error checking on the return value is performed in the base class.
protected virtual override MLResult.Code StopAPI()
Reimplements: StopAPI
Public Attributes
VoiceEnabled
Checks voice intent feature is enabled in the system.
public static bool VoiceEnabled => Instance.isEnabled();
Public Enums
NoIntentReason
No intent reason code in voice event.
Enumerator | Value | Description |
---|---|---|
NoReason | In case of success | |
Silence | When the State in IntentEvent is either MLVoice.State.SessionEndedTimeout or MLVoice.State.SessionEndedError. | |
NoMatch | When the State in IntentEvent is MLVoice.State.SessionEndedNoIntent. |
State
Voice state in voice event.
Enumerator | Value | Description |
---|---|---|
HotwordDetected | Intent hotword detected, Automatic Speech Recognition (ASR) session is going to start. | |
SessionEnded | Voice UI is stopped, ASR session is going to stop. | |
ISessionEndedAborted | ASR session is stopped due to abort. | |
SessionEndedNoIntent | ASR session is stopped without detecting an intent. | |
SessionEndedTimeout | ASR session is stopped due to timeout. | |
SessionEndedError | ASR session is stopped due to error. | |
Ready | Intent mode is started and ready. | |
NotAvailable | Intent mode is stopped and not available. |