[英]Recognize the custom speech keywords (Unity, MRTK, Hololens 1)
I'm trying to get the hololens (1) to recognize a custom defined speech keyword.我试图让 hololens (1) 识别自定义定义的语音关键字。 Using Unity and MRTK.使用 Unity 和 MRTK。 It recognizes the pre-defined keywords (ex: "Select") but my custom keyword (let's call it "Keyword") isn't recognized.它可以识别预定义的关键字(例如:“选择”),但无法识别我的自定义关键字(我们称之为“关键字”)。
I have both a tooltip pop up to give feedback if it recognized a keyword and a audio feedback I put in there for debugging purposes (aka: if ANY keyword is recognized, play a chime).如果它识别出一个关键字,我会弹出一个工具提示来提供反馈,还有一个我放在那里用于调试目的的音频反馈(又名:如果识别出任何关键字,播放一个铃声)。 It works for "Select" but not for "Keyword."它适用于“选择”,但不适用于“关键字”。
I want this keyword to be globally recognized.我希望这个关键字被全球认可。
I have tried several different keywords to make sure I didn't pick a difficult to recognize one.我尝试了几个不同的关键字,以确保我没有选择一个难以识别的关键字。
using UnityEngine; using Microsoft.MixedReality.Toolkit.Input; using Microsoft.MixedReality.Toolkit; public class SpeechManager: MonoBehaviour, IMixedRealitySpeechHandler { void Start() { //Debugging "play sound" declarations deleted as not important for this example script. CoreServices.InputSystem?.RegisterHandler<IMixedRealitySpeechHandler>(this); } void IMixedRealitySpeechHandler.OnSpeechKeywordRecognized(SpeechEventData eventData) { PlaySound(1); //DEBUG AUDIO FEEDBACK if (eventData.Command.Keyword == "keyword") { PlaySound(2); //DEBUG AUDIO FEEDBACK } else if (eventData.Command.Keyword == "select") { PlaySound(3); //DEBUG AUDIO FEEDBACK } } }
What SHOULD happen:应该发生什么:
"Select" spoken: PlaySound(1) and PlaySound(3) triggered.说出“选择”:触发 PlaySound(1) 和 PlaySound(3)。
"Keyword" spoken: PlaySound(1) and PlaySound(2) triggered.说出“关键字”:触发 PlaySound(1) 和 PlaySound(2)。
What ACTUALLY happens:实际发生的情况:
"Select": PlaySound(1) triggered* “选择”:PlaySound(1) 触发*
"Keyword" nothing happens <- Why? “关键字”什么也没发生 <- 为什么? WHY???为什么???
'* Yes, PlaySound(3) is not triggered, but that is a whole separate issue that I'm not too concerned about because both Speech Input Handler and Input Action Handler both recognize "Select." '* 是的,PlaySound(3) 没有被触发,但这是一个完全独立的问题,我不太关心,因为语音输入处理程序和输入操作处理程序都识别“选择”。 One issue at a time!一次一个问题!
Perazim, thank you for your input. Perazim,感谢您的意见。 Mine looks exactly like yours.我的和你的一模一样。 So why wasn't it working?那么为什么它不起作用呢? I figured it out.我想到了。 Another user on another problem solved their problem by deleting the App folder (or whatever you named your build folder).另一个问题的另一个用户通过删除 App 文件夹(或任何您命名的构建文件夹)解决了他们的问题。 So i thought, let's give it a try.所以我想,让我们试一试。 It worked:,!有效:,! Tip to save you massive amount of time: if you think it should work and it doesn't, delete App!!!为您节省大量时间的提示:如果您认为它应该有效而无效,请删除应用程序!!!
I can share how I set up my scene and my words are getting recognized.我可以分享我是如何设置场景的,并且我的文字得到了认可。 I attach the SpeechInputHandler
eg on my toolbar and reference my keywords to the toolbar buttons.我将SpeechInputHandler
例如附加在我的工具栏上,并将我的关键字引用到工具栏按钮。 Is Focus Required
is also set to false
. Is Focus Required
也设置为false
。
1. Define your keyword under MRT>Input>Speech
: 1. 在MRT>Input>Speech
下定义你的关键词:
2. Setup the Speech Input Handler
: 2.设置Speech Input Handler
程序:
You could also try the newer speech platform.您也可以尝试更新的语音平台。 It supports unity, and it's available here: http://aka.ms/speech/sdk .它支持统一,可在此处获得: http://aka.ms/speech/sdk 。 Some find it easier to use.有些人发现它更容易使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.