如何在语音转文本(Unity IBM Watson sdk)中检测句子检测是否完成?
How to detect if a sentence detection is finished in speech-to-text (Unity IBM Watson sdk)?
我想在每次检测完一个句子时将句子发送到服务器。
例如,当它检测到我说话时"How do I do"。我想将这句话发送到服务器。但是,每次尝试组成一个句子时都会调用以下方法。比如我说"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;
}
}
}
}
}
响应对象中有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
}
}
}
}
}
}
我想在每次检测完一个句子时将句子发送到服务器。
例如,当它检测到我说话时"How do I do"。我想将这句话发送到服务器。但是,每次尝试组成一个句子时都会调用以下方法。比如我说"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;
}
}
}
}
}
响应对象中有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
}
}
}
}
}
}