我正在使用tensorflow-models / speech-commands模型来使用ReactJs应用程序检测语音命令,我能够在应用程序中初始化识别器并获取结果,但不确定如何根据模型结果识别标签。
componentDidMount () {
fetch("http://localhost:3001/ITEMS").then(resp => resp.json())
.then(result => this.setState({
products: result
},() => {
this.call()
}));
}
async call() {
const recognizer = speechCommands.create('BROWSER_FFT')
await recognizer.ensureModelLoaded();
console.log("CALL",recognizer)
recognizer.listen(result => {
// - result.scores contains the probability scores that correspond to
// recognizer.wordLabels().
// - result.spectrogram contains the spectrogram of the recognized word.
console.log("Result",result)
}, {
includeSpectrogram: true,
probabilityThreshold: 0.75
});
// Stop the recognition in 10 seconds.
setTimeout(() =>{
console.log("Stopped listening")
recognizer.stopListening()}, 10000);
}
如您所见,我正在将识别器初始化为did Mount,并获得来自我的语音命令的结果,但不确定如何准确识别从结果中检测到的标签模型。
我相信我应该参考scores属性,但是确切地说是预测的,不确定。请帮忙。