# Speech commands in MRTK not working in OpenXR (Solved)

**URL:** <https://forum.magicleap.cloud/t/speech-commands-in-mrtk-not-working-in-openxr-solved/4912>\
**Category:** OpenXR\
**Tags:** unity, mrtk3\
**Created:** [January 2, 2025, 3:57pm UTC](https://forum.magicleap.cloud/t/speech-commands-in-mrtk-not-working-in-openxr-solved/4912 "2025-01-02T15:57:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![localjoost](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/localjoost/32/1829_2.png) [@localjoost](https://forum.magicleap.cloud/u/localjoost)\
**Post date:** [January 2, 2025, 3:57pm UTC](https://forum.magicleap.cloud/t/speech-commands-in-mrtk-not-working-in-openxr-solved/4912/1 "2025-01-02T15:57:24Z")

</div>

After vainly trying to get speech commands to work in my own app, I

- pulled your own [Magic Leap MRTK code from Github](https://github.com/magicleap/MixedRealityToolkit-Unity.git)
- switched to mrtk3\_MagicLeap2\_OpenXR
- Built the app with as only active scene the SpeechInputExamples scene
- Deployed the app on my ML2
- Run it,
- Asks for 3 permissions, voice input is one of them
- scene opens
- No response to any speech commands.

The funny things is, it works fine in the Unity editor

Used:

- Unity 2022.3.40f1
- Magic Leap OS 1.11.0

Edit: also tried:

- pulling mrtk3\_Unity6\_MagicLeap2
- using Unity 6000.0.25f1

Same result. No speech command, although the app asks for voice input permissions on startup

What's going on here?

---

<div class="post-metadata">

**Author:** ![localjoost](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/localjoost/32/1829_2.png) [@localjoost](https://forum.magicleap.cloud/u/localjoost)\
**Post date:** [January 6, 2025, 7:19am UTC](https://forum.magicleap.cloud/t/speech-commands-in-mrtk-not-working-in-openxr-solved/4912/2 "2025-01-06T07:19:29Z")

</div>

Right. So you have to enable voice commands at SYSTEM LEVEL. I probably turned that on ages ago, forgot about it, and after an OS upgrade haywire I flashed the device I got the default setting back, which is off.

May I respectfully point out it's a bit weird the device actually asks for permission for a permission it cannot use because it's turned off? Maybe it's a good idea to actually give a hint for that in the prompt when it asks for permission?

---

<div class="post-metadata">

**Author:** ![kbabilinski](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/kbabilinski/32/19_2.png) [@kbabilinski](https://forum.magicleap.cloud/u/kbabilinski)\
**Post date:** [January 6, 2025, 4:10pm UTC](https://forum.magicleap.cloud/t/speech-commands-in-mrtk-not-working-in-openxr-solved/4912/3 "2025-01-06T16:10:51Z")

</div>

I have reported your feedback to our voice of customer team. In the meantime, you may be able check the current system settings via an Android object. You can reference the JavaUtils script inside the MRTK 3 package.

Here is a simplified example of how you could read the system settings:

```csharp
  private void ReadSystemVoiceInputSettings()
    {
        try
        {
            // Access the UnityPlayer class to get the current Android activity
            AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");

            // Get the ContentResolver from the current activity
            AndroidJavaObject contentResolver = currentActivity.Call<AndroidJavaObject>("getContentResolver");

            // Access the android.provider.Settings$System class
            AndroidJavaClass systemSettings = new AndroidJavaClass("android.provider.Settings$System");

            // Read the value of the system setting "enable_voice_cmds"
            int mlVoiceEnabled = systemSettings.CallStatic<int>("getInt", contentResolver, "enable_voice_cmds");

            // Check the value and log the result
            if (mlVoiceEnabled == 1)
            {
                Debug.Log("ML Voice Input is Enabled");
            }
            else
            {
                Debug.Log("ML Voice Input is Disabled");
            }
        }
        catch (AndroidJavaException e)
        {
            // Handle potential exceptions (e.g., setting not found or permission issues)
            Debug.LogError("Error reading system settings: " + e.Message);
        }
    }

```

---

<div class="post-metadata">

**Author:** ![localjoost](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/localjoost/32/1829_2.png) [@localjoost](https://forum.magicleap.cloud/u/localjoost)\
**Post date:** [January 7, 2025, 5:46am UTC](https://forum.magicleap.cloud/t/speech-commands-in-mrtk-not-working-in-openxr-solved/4912/4 "2025-01-07T05:46:51Z")

</div>

Thanks! That is useful!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/magicleap1/original/1X/bd9b737a4d45ea243aa7eb177d60a773b806899a.svg) [@system](https://forum.magicleap.cloud/u/system)\
**Post date:** [January 22, 2025, 5:47am UTC](https://forum.magicleap.cloud/t/speech-commands-in-mrtk-not-working-in-openxr-solved/4912/5 "2025-01-22T05:47:41Z")

</div>

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.
