Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MRTK3's DictationExmple scene is broken. Need to disable keyword recognition before enabling dictation #63

Closed
IssueSyncBot opened this issue Aug 20, 2023 · 1 comment
Assignees

Comments

@IssueSyncBot
Copy link

IssueSyncBot commented Aug 20, 2023

Original issue opened by:

@AMollis AMollis


Overview

MRTK3's DictationExmple scene is broken. Need to disable keyword recognition before enabling dictation. See code in NonNativeKeyboard for a possible solution:

        /// <summary>
        /// Start dictation on a DictationSubsystem.
        /// </summary>
        public void StartDictation()
        {
            var dictationSubsystem = XRSubsystemHelpers.DictationSubsystem;
            if (dictationSubsystem != null && !isRecording)
            {
                isRecording = true;
                UpdateDictationRecordIconColor();

                keywordRecognitionSubsystem = XRSubsystemHelpers.KeywordRecognitionSubsystem;
                if (keywordRecognitionSubsystem != null)
                {
                    keywordRecognitionSubsystem.Stop();
                }

                ResetClosingTime();
                dictationSubsystem.Recognized += OnDictationRecognizedResult;
                dictationSubsystem.RecognitionFinished += OnDictationFinished;
                dictationSubsystem.RecognitionFaulted += OnDictationFaulted;
                dictationSubsystem.StartDictation();
            }
        }

        /// <summary>
        /// Called when dictation is completed
        /// </summary>
        /// <param name="eventData">Dictation event data</param>
        private void OnDictationFinished(DictationSessionEventArgs eventData)
        {
            HandleDictationShutdown();
        }

        /// <summary>
        /// Called when dictation is faulted
        /// </summary>
        /// <param name="eventData">Dictation event data</param>
        private void OnDictationFaulted(DictationSessionEventArgs eventData)
        {
            Debug.LogError("Dictation faulted. Reason: " + eventData.Reason);
            HandleDictationShutdown();
        }

        /// <summary>
        /// Release references to dictation events
        /// </summary>
        private void HandleDictationShutdown()
        {
            var dictationSubsystem = XRSubsystemHelpers.DictationSubsystem;
            if (dictationSubsystem != null)
            {
                dictationSubsystem.RecognitionFinished -= OnDictationFinished;
                dictationSubsystem.RecognitionFaulted -= OnDictationFaulted;
                dictationSubsystem.Recognized -= OnDictationRecognizedResult;

                isRecording = false;
                UpdateDictationRecordIconColor();
            }

            if (keywordRecognitionSubsystem != null)
            {
                keywordRecognitionSubsystem.Start();
                keywordRecognitionSubsystem = null;
            }
        }

Repo Steps

  1. Build and deploy a UWP containing the DictationExample scene
  2. Click the "start dictation" button
  3. Nothing happens

ISSUE MIGRATION

Issue migrated from: microsoft/MixedRealityToolkit-Unity#11690

@IssueSyncBot
Copy link
Author

Original comment by:

@marlenaklein-msft marlenaklein-msft


Closed with #11696.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants