gpt4 book ai didi

angular - 如何在 IONIC 中使用连续语音转文本

转载 作者:行者123 更新时间:2023-12-05 07:37:14 29 4
gpt4 key购买 nike

我已经成功整合Speech Recognition我项目中的 API(IONIC 3)。但是要输入语音,我需要每次都调用 this.speechRecognition.startListening。

有什么方法可以让我持续将其作为服务器运行?因此,在任何时候,如果有人说了些什么,它就会转换为文本。

最佳答案

我提出了我的解决方案,无法通过插件正式使用继续收听。但我们可以使用递归概念来实现这一点。

 this.speechRecognition.startListening(option).subscribe((matches: Array<string>) => { 
this.voiceArray = matches;
// Now we get what user said so we can call again for active start listening.
this.start();
}, (onerror) => {
console.log('Error::::', onerror);
// Error occure when user does not say anything in that case we can call again.
this.start();
}

注意:将所有监听代码放在start() 函数中并调用它。但是您必须不断处理那烦人的哔哔声。为此,您可以使用 cordova audioManagment 插件(这将使用户设备静音,但并非一直都适用)。

关于angular - 如何在 IONIC 中使用连续语音转文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48767034/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com