在 IBM Watson unity SDK 中获取时间戳
Getting timestamps in IBM Watson unity SDK
如何在 IBM Watson Speech to Text Unity SDK 中访问单词的时间戳?
这是我正在使用的代码片段。我能够获得给定音频的正确转录本,但时间戳 变量仍然为 Null.
[SerializeField]
private AudioClip m_AudioClip = new AudioClip();
private SpeechToText m_SpeechToText = new SpeechToText();
void Start()
{
Debug.Log("start");
m_SpeechToText.EnableTimestamps = true;
m_SpeechToText.Recognize(m_AudioClip, OnRecognize);
}
void OnRecognize(SpeechRecognitionEvent result)
{
Debug.Log("Here");
if (result != null && result.results.Length > 0)
{
foreach (var res in result.results)
{
foreach (var alt in res.alternatives)
{
var timestamps = alt.timestamps;
Debug.Log(timestamps);
}
}
}
}
您可以在 Speech Recognition Alternatives 对象中找到时间戳。
void OnRecognize(SpeechRecognitionEvent result)
{
Debug.Log("Here");
if (result != null && result.results.Length > 0)
{
foreach (var res in result.results)
{
foreach (var alt in res.alternatives)
{
if (alt.Timestamps != null)
foreach (var timestamp in alt.Timestamps)
Debug.Log(string.Format("timestamp word: {0}, start: {1}, end: {2}", timestamp.Word, timestamp.Start, timestamp.End));
}
}
}
}
如何在 IBM Watson Speech to Text Unity SDK 中访问单词的时间戳?
这是我正在使用的代码片段。我能够获得给定音频的正确转录本,但时间戳 变量仍然为 Null.
[SerializeField]
private AudioClip m_AudioClip = new AudioClip();
private SpeechToText m_SpeechToText = new SpeechToText();
void Start()
{
Debug.Log("start");
m_SpeechToText.EnableTimestamps = true;
m_SpeechToText.Recognize(m_AudioClip, OnRecognize);
}
void OnRecognize(SpeechRecognitionEvent result)
{
Debug.Log("Here");
if (result != null && result.results.Length > 0)
{
foreach (var res in result.results)
{
foreach (var alt in res.alternatives)
{
var timestamps = alt.timestamps;
Debug.Log(timestamps);
}
}
}
}
您可以在 Speech Recognition Alternatives 对象中找到时间戳。
void OnRecognize(SpeechRecognitionEvent result)
{
Debug.Log("Here");
if (result != null && result.results.Length > 0)
{
foreach (var res in result.results)
{
foreach (var alt in res.alternatives)
{
if (alt.Timestamps != null)
foreach (var timestamp in alt.Timestamps)
Debug.Log(string.Format("timestamp word: {0}, start: {1}, end: {2}", timestamp.Word, timestamp.Start, timestamp.End));
}
}
}
}