我正在尝试在 Watson 的 Speech-To-Text 中指定关键字Unity SDK
,但我不确定如何执行此操作。
详细信息页面未显示示例(请参见此处:https ://www.ibm.com/watson/developercloud/doc/speech-to-text/output.shtml ),
和其他论坛帖子是为 Java 应用程序编写的(请参阅此处:如何为 IBM Watson Speech2text 服务指定语音关键字?)。
我已经尝试RecognizeRequest
像这样在“识别”函数中创建的类中对这些值进行硬编码,但没有成功:
**编辑——这个函数永远不会被调用——**
public bool Recognize(AudioClip clip, OnRecognize callback)
{
if (clip == null)
throw new ArgumentNullException("clip");
if (callback == null)
throw new ArgumentNullException("callback");
RESTConnector connector = RESTConnector.GetConnector(SERVICE_ID, "/v1/recognize");
if (connector == null)
return false;
RecognizeRequest req = new RecognizeRequest();
req.Clip = clip;
req.Callback = callback;
req.Headers["Content-Type"] = "audio/wav";
req.Send = WaveFile.CreateWAV(clip);
if (req.Send.Length > MAX_RECOGNIZE_CLIP_SIZE)
{
Log.Error("SpeechToText", "AudioClip is too large for Recognize().");
return false;
}
req.Parameters["model"] = m_RecognizeModel;
req.Parameters["continuous"] = "false";
req.Parameters["max_alternatives"] = m_MaxAlternatives.ToString();
req.Parameters["timestamps"] = m_Timestamps ? "true" : "false";
req.Parameters["word_confidence"] = m_WordConfidence ? "true" :false";
//these "keywords" and "keywords_threshold" and "keywordsThreshold" parameters
//are just my guess for how to set these values
req.Parameters["keywords"] = new string[] {"fun", "match", "test" };
req.Parameters["keywordsThreshold"] = .2;
req.Parameters["keywords_threshold"] = .2;
//end my test insertions
req.OnResponse = OnRecognizeResponse;
return connector.Send(req);
}
但返回的SpeechRecognitionEvent
结果值不包含任何keywords_result
. 这是我的目标。我试图像这样查看keywords_result 对象中每个关键字的置信度,但该keywords_result
对象返回为null
.
private void OnRecognize(SpeechRecognitionEvent result) {
Debug.Log("Recognizing!");
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) {
//the res.keywords_result comes back as null
foreach (var keyword in res.keywords_result.keyword) {
string text = keyword.normalized_text;
float confidence = keyword.confidence;
Debug.Log(text + ": " + confidence);
}
}
}
}
有没有人在 Unity 或 C# 中使用 Watson 的 Speech-To-Text SDK 成功实施了关键字置信度评估?欢迎所有想法和建议。
PS这是我的第一篇文章:)