C# 使用IBM Watson的speech to text会导致在识别关键字时多次调用该方法

C# 使用IBM Watson的speech to text会导致在识别关键字时多次调用该方法,c#,unity3d,speech-recognition,ibm-watson,speech-to-text,C#,Unity3d,Speech Recognition,Ibm Watson,Speech To Text,我在Unity程序中使用IBM Watson Speech To Text来识别语音。在识别语音的onRecognize方法中,我放置了一个if语句,如果它识别出关键字go,它将调用一个方法。虽然,当识别出go这个词时,该方法会被调用两到三次,而不是像它应该调用的那样调用一次,这会导致程序无法按它应该的方式工作 我想不出任何解决方案,因为这是没有什么我可以做的改变代码 //All of this is inside of the onRecognize() method string text

我在Unity程序中使用IBM Watson Speech To Text来识别语音。在识别语音的onRecognize方法中,我放置了一个if语句,如果它识别出关键字go,它将调用一个方法。虽然,当识别出go这个词时,该方法会被调用两到三次,而不是像它应该调用的那样调用一次,这会导致程序无法按它应该的方式工作

我想不出任何解决方案,因为这是没有什么我可以做的改变代码

//All of this is inside of the onRecognize() method
string text = string.Format("{0} ({1}, {2:0.00})\n", alt.transcript, res.final ? "Final" : "Interim", alt.confidence);
Log.Debug("ExampleStreaming.OnRecognize()", text);
ResultsField.text = text;

//This if statement inside of the onRecognize() method will play an 
//animation if it detects the word "go"
if (alt.transcript.Contains("go"))
{
    anim.Play("move", -1, 0f); //This will play an animation.
}

我希望下面的代码段在检测到go这个词时只调用该方法一次,但是它会被调用两到三次。这使得它看起来像马车,而不是我想要的。如有任何帮助,将不胜感激。

是否添加res.final的检查

if (res.final && alt.transcript.Contains("go"))
{
    anim.Play("move", -1, 0f); //This will play an animation.
}

嘿@Nikolay Shmyrev,我想知道你能否帮我回答另一个语音识别问题,如果你能帮忙,那太棒了!如果没有,那就完全好了。非常感谢。