Hello everyone.

The Mixed Reality Forums here are no longer being used or maintained.

There are a few other places we would like to direct you to for support, both from Microsoft and from the community.

The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.

For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.

If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.

And always feel free to hit us up on Twitter @MxdRealityDev.

KeywordRecognizer does not start

Hi,
I followed the example from the Hololen 101 tutorial for voice.
But somehow I cannot make it work.
From what I see, it looks like the recognizer is not running after starting it.

This is my code:


`
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.Windows.Speech;

public class SpeechManager : MonoBehaviour
{
KeywordRecognizer keywordRecognizer = null;
Dictionary<string, System.Action> keywords = new Dictionary<string, System.Action>();

// Use this for initialization
void Start()
{
    try
    {
        keywords.Add("Home", () =>
        {
            // Call the OnReset method on every descendant object.
            this.BroadcastMessage("OnGoHome");
        });

        keywords.Add("Back", () =>
        {
            // Call the OnReset method on every descendant object.
            this.BroadcastMessage("OnGoBack");
        });

        // Tell the KeywordRecognizer about our keywords.
        keywordRecognizer = new KeywordRecognizer(keywords.Keys.ToArray());

        // Register a callback for the KeywordRecognizer and start recognizing!
        keywordRecognizer.OnPhraseRecognized += KeywordRecognizer_OnPhraseRecognized;
        keywordRecognizer.Start();

        DebugWindow.Instance.Text = keywordRecognizer.IsRunning ? "Ok" : "KO";
    }
    catch (Exception ex)
    {
        DebugWindow.Instance.Text = "SpeechManager - Error - " + ex.Message;
    }
}

private void KeywordRecognizer_OnPhraseRecognized(PhraseRecognizedEventArgs args)
{
    DebugWindow.Instance.Text = "Beta - " + args.text;
    System.Action keywordAction;
    if (keywords.TryGetValue(args.text, out keywordAction))
    {
        DebugWindow.Instance.Text = "Gamma";
        keywordAction.Invoke();
    }
}

}`


When I debug using the Unity debugger, I see 'OK' in my debug window.
When I debug on my HoloLens I see 'KO' instead.

For the Unity Build capacities I have:

  • InternetClient
  • Microphone
  • SpatialPerception
Tagged:

Best Answer

Answers

Sign In or Register to comment.