【发布时间】:2021-01-04 07:01:28
【问题描述】:
当我说出一个句子“在我附近放映 tenet 电影”时,语音识别 API 会自动将我的句子更改为“在我附近放映 今晚电影”,问题出在这个词上宗旨改为今晚
【问题讨论】:
标签: javascript speech-recognition speech-to-text webspeech-api webkitspeechrecognition
当我说出一个句子“在我附近放映 tenet 电影”时,语音识别 API 会自动将我的句子更改为“在我附近放映 今晚电影”,问题出在这个词上宗旨改为今晚
【问题讨论】:
标签: javascript speech-recognition speech-to-text webspeech-api webkitspeechrecognition
您是否尝试过检查替代方案?您可以将 maxAlternatives 设置为 20 之类的高值,然后使用诸如此类的函数来检查其中一个是否包含您要查找的短语。
将您的短语作为数组传递,并从 SpeechRecognition 收到结果。
function ExtractTranscript(phrases, results) {
// Loop through the alternatives to check if any of our phrases are contained in them.
for (let result in results[0]) {
if (new RegExp(phrases.join("|")).test(results[0][result].transcript)) {
return results[0][result].transcript; // Return the alternative if they are
}
}
return results[0][0].transcript; // Otherwise return the one with the highest confidence
}
这也依赖于 API 词汇表中的“信条”一词。
【讨论】: