IBM Watson Speech to Text Unity SDKの単語のタイムスタンプにアクセスするにはどうすればよいですか?
これは私が使用しているコードスニペットです。特定のオーディオの正しいトランスクリプトを取得できますが、timestamp変数は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);
}
}
}
}
タイムスタンプはSpeechRecognitionAlternativesオブジェクトにあります。
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));
}
}
}
}
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加