Hello,
My Unity project has the Unity SDK version 1.9.0, and the Magic Leap device itself is version 1.4.0 (dev1). When using voice intents, it successfully starts and MLVoice.IsStarted returns true. On the device itself, the app has the Voice Input and Microphone permissions set to "Allowed". Voice Input is also enabled in Settings -> Magic Leap Inputs -> Voice Input.
However, when I say any of my voice intents, the OnVoiceEvent does not print anything out. This project worked a few weeks ago, so I'm not sure what is different between now and then besides a more up to date SDK and device OS version. I've attached a screenshot of my script and my voice intents.
public class CustomVoice : MonoBehaviour
{
// Voice Configuration that will be created at runtime.
[SerializeField] private MLVoiceIntentsConfiguration _voiceConfiguration;
[SerializeField] private QRCodeCalibration calibration;
private readonly MLPermissions.Callbacks permissionCallbacks = new MLPermissions.Callbacks();
// Start is called before the first frame update
void Start()
{
// Configure the voice intents based on the new configuration.
MLResult result = MLVoice.SetupVoiceIntents(_voiceConfiguration);
if (result.IsOk)
{
Debug.Log("Successful: " + MLVoice.IsStarted); // This is printing out "Successful: True"
MLVoice.OnVoiceEvent += OnVoiceEvent;
}
else
{
Debug.LogError("Failed to Setup Voice Intents with result: " + result);
}
}
// Stop the service and disable the event when the script is destroyed.
private void OnDestroy()
{
MLVoice.Stop();
MLVoice.OnVoiceEvent -= OnVoiceEvent;
}
// Write a message to the log when a command was detected.
void OnVoiceEvent(in bool wasSuccessful, in MLVoice.IntentEvent voiceEvent)
{
Debug.Log("Received voice: " + voiceEvent.EventName); // this is never getting printed
switch (voiceEvent.EventName) {
case "Next Task":
{
TaskManager.main.NextTask();
break;
}
case "Next Step":
{
TaskManager.main.NextTask();
break;
}
case "Previous Task":
{
TaskManager.main.PreviousTask();
break;
}
case "Previous Step":
{
TaskManager.main.PreviousTask();
break;
}
case "End Sequence":
{
TaskManager.main.EndSequence();
break;
}
case "Show Visuals":
{
TaskManager.main.ShowTaskVisuals(true);
break;
}
case "Hide Visuals":
{
TaskManager.main.ShowTaskVisuals(false);
break;
}
case "Calibrate":
{
calibration.StartCalibration();
break;
}
case "Recalibrate":
{
calibration.StartCalibration();
break;
}
case "Repeat Step":
{
TaskManager.main.RepeatTask();
break;
}
case "Repeat Task":
{
TaskManager.main.ResetSequence();
break;
}
}
Debug.Log("Detected Voice Command : " + voiceEvent.EventName);
}
}
Thank you.