0

我现在正在使用 Visual Studio 2017 为 Microsoft Hololens 编写应用程序。目标是使用语音识别语法规范进行语音识别。

我在笔记本电脑上尝试了我的解决方案,它运行良好,但不知何故它不适用于 Hololens 模拟器。问题是最基本的。单词无法识别。编译没有问题,找到 grxml 文件也没有问题。其次,RecognizeWithUIAsync() 窗口不会弹出。

C#:

        // Create an instance of SpeechRecognizer
        var speechRecognizer = new SpeechRecognizer(language);

        // Load Grammar depending on the selected language
        var storageFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Grammar/grammatik_de.grxml"));
        var grammarFileConstraint = new SpeechRecognitionGrammarFileConstraint(storageFile, "grammatik");


            storageFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Grammar/grammatik_eng.grxml"));
            grammarFileConstraint = new SpeechRecognitionGrammarFileConstraint(storageFile, "grammatik");

            speechRecognizer.UIOptions.ExampleText = @"Example: Stop all vehicles,Fork higher,Fork lower,Vehicle Forward,Drive Backwards";


        // Compile the constraint.
        await speechRecognizer.CompileConstraintsAsync();

        // Start recognition.
        SpeechRecognitionResult speechRecognitionResult = await speechRecognizer.RecognizeWithUIAsync(); 

       //do something with the result
        try
        {
            String action = grammarHandling(speechRecognitionResult);
            actionOnSpeechAsync(action);
        }
        catch (Exception) { 
        }
4

1 回答 1

0

I know you mentioned usage of SRGS, but would the use of Speech Input Handler and Speech Input Source scripts, built into Mixed Reality Toolkit, help you with your application? I have used it a lot and never seemed to have any problems. It's also easy to debug it.

Regards

于 2018-11-08T09:23:49.213 回答