我正在尝试在开始收听语音时捕获文本,但是我不知道如何实现。
这是我当前拥有的代码:
// Start the recognition process
this.speechRecognition.startListening(options)
.subscribe(
(matches: string[]) => {
console.log(matches);
this.cd.detectChanges();
for (let index = 0; index < matches.length; index++) {
this.texto.push( matches[index] );
}
alert('Empezar a escuchar');
this.cd.detectChanges();
},
(onerror) => {
console.log('error:', onerror);
alert('error' + JSON.stringify(onerror));
}
)