【问题标题】:How to detect if a sentence detection is finished in speech-to-text (Unity IBM Watson sdk)?如何检测是否在语音到文本(Unity IBM Watson sdk)中完成了句子检测?
【发布时间】:2017-07-26 00:32:32
【问题描述】:

我想在每次完成检测句子时将句子发送到服务器。

例如,当它检测到我说“我该怎么做”时。我想将这句话发送到服务器。但是,每次尝试组成句子时都会调用以下方法。比如我说“How do I do”的时候,会打印出“how”、“how do”、“how do I do”,有什么地方可以知道一句话说完了吗?

private void OnRecognize(SpeechRecognitionEvent result)
{
    m_ResultOutput.SendData(new SpeechToTextData(result));

    if (result != null && result.results.Length > 0)
    {
        if (m_Transcript != null)
             m_Transcript.text = "";

        foreach (var res in result.results)
        {
            foreach (var alt in res.alternatives)
            {
                string text = alt.transcript;

                if (m_Transcript != null)
                {
                        //   print(text);

                        //m_Transcript.text += string.Format("{0} ({1}, {2:0.00})\n",
                        //    text, res.final ? "Final" : "Interim", alt.confidence);

                        m_Transcript.text = text;
                }
            }       
        }   
    }
}

【问题讨论】:

  • 这似乎是在句被识别之后运行的代码,但您似乎需要识别方面的帮助?告诉我们这个事件是在哪里引发的! (免责声明:我不熟悉沃森认知)

标签: unity3d ibm-watson


【解决方案1】:

响应对象中有一个final 属性。

private void OnRecognize(SpeechRecognitionEvent result)
{
    m_ResultOutput.SendData(new SpeechToTextData(result));

    if (result != null && result.results.Length > 0)
    {
        if (m_Transcript != null)
             m_Transcript.text = "";

        foreach (var res in result.results)
        {
            foreach (var alt in res.alternatives)
            {
                string text = alt.transcript;

                if (m_Transcript != null)
                {
                    // print(text);

                    //m_Transcript.text += string.Format("{0} ({1}, {2:0.00})\n",
                    //  text, res.final ? "Final" : "Interim", alt.confidence);

                    if(res.final)
                    {
                        m_Transcript.text = text;
                        //  do something with the final transcription
                    }
                }
            }       
        }   
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-01
    • 2019-06-23
    • 1970-01-01
    • 2012-06-12
    • 2017-11-30
    相关资源
    最近更新 更多