microsoft / MixedRealityToolkit-Unity

This repository is for the legacy Mixed Reality Toolkit (MRTK) v2. For the latest version of the MRTK please visit https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity
https://aka.ms/mrtkdocs
MIT License
6k stars 2.12k forks source link

Cannot simulate voice commands via keyboard on a Mac #5394

Closed julenka closed 9 months ago

julenka commented 5 years ago

Describe the bug

Simulating voice commands in editor via keyboard keys can greatly increase productivity. However, voice commands only work if you are running Unity on a Windows Machine -- they will not work if running on a Mac

To reproduce

  1. Open up MRTK on a Mac
  2. Start HandInteractionExample scene.
  3. Press '0' key

Expected: Profiler hides (0 triggers 'toggle profiler' command)

Actual: nothing happens (no voice command gets triggered)

Workaround

As a workaround, you can put the following script attached to a game object in a scene -- it will fire voice commands in response to the proper keys.

using UnityEngine;
using System;
using Microsoft.MixedReality.Toolkit.Input;
using Microsoft.MixedReality.Toolkit;
using Microsoft.MixedReality.Toolkit.Utilities;

public class SimpleSpeechInputProvider : MonoBehaviour
{
    private IMixedRealityInputSystem inputSystem = null;

    protected IMixedRealityInputSystem InputSystem
    {
        get
        {
            if (inputSystem == null)
            {
                MixedRealityServiceRegistry.TryGetService<IMixedRealityInputSystem>(out inputSystem);
            }
            return inputSystem;
        }
    }

    private IMixedRealityInputSource inputSource;
    private IMixedRealityInputSource InputSource
    {
        get 
        {
            if (inputSource != null)
            {
                return inputSource;
            }
            inputSource = InputSystem?.RequestNewGenericInputSource("Windows Speech Input Source", sourceType: InputSourceType.Voice);
            return inputSource;
        }
    }

    public void Update()
    {
        var speechCommands = MixedRealityToolkit.Instance.ActiveProfile.InputSystemProfile.SpeechCommandsProfile.SpeechCommands;

        for (int i = 0; i < speechCommands.Length; i++)
        {
            if (Input.GetKeyDown(speechCommands[i].KeyCode))
            {
                InputSystem?.RaiseSpeechCommandRecognized(
                    InputSource, 
                    RecognitionConfidenceLevel.High, 
                    TimeSpan.FromSeconds(1.0), 
                    DateTime.Now, 
                    speechCommands[i]);
            }
        }
    }   
}
stale[bot] commented 4 years ago

This issue has been marked as stale by an automated process because it has not had any recent activity. It will be automatically closed in 30 days if no further activity occurs. If this is still an issue please add a new comment with more recent details and repro steps.

stale[bot] commented 4 years ago

This issue has been closed by an automated process because it is stale. If this is still an issue please add a new comment with more recent details and repro steps.

julenka commented 4 years ago

Re-opening as I just verified that simulating voice commands still do not work on Mac OSX.

stale[bot] commented 4 years ago

This issue has been marked as stale by an automated process because it has not had any recent activity. It will be automatically closed in 30 days if no further activity occurs. If this is still an issue please add a new comment with more recent details and repro steps.

stale[bot] commented 4 years ago

This issue has been closed by an automated process because it is stale. If this is still an issue please add a new comment with more recent details and repro steps.

stale[bot] commented 2 years ago

This issue has been marked as stale by an automated process because it has not had any recent activity. It will be automatically closed in 30 days if no further activity occurs. If this is still an issue please add a new comment with more recent details and repro steps.

IssueSyncBot commented 9 months ago

We appreciate your feedback and thank you for reporting this issue.

Microsoft Mixed Reality Toolkit version 2 (MRTK2) is currently in limited support. This means that Microsoft is only fixing high priority security issues. Unfortunately, this issue does not meet the necessary priority and will be closed. If you strongly feel that this issue deserves more attention, please open a new issue and explain why it is important.

Microsoft recommends that all new HoloLens 2 Unity applications use MRTK3 instead of MRTK2.

Please note that MRTK3 was released in August 2023. It features an all-new architecture for developing rich mixed reality experiences and has a minimum requirement of Unity 2021.3 LTS. For more information about MRTK3, please visit https://www.mixedrealitytoolkit.org.

Thank you for your continued support of the Mixed Reality Toolkit!