语音识别模块

最后更新于:2022-04-01 23:48:45

# 语音识别模块--很轻松加载 > 加入第三方模块 ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/9bda32f099a45e54050a33b24df2b86d_509x170.png) **注:不需要配置任何文件** > 项目代码实例--语音输入文档--点击输入以及点击方法 **html--部分** ~~~
开始录音
~~~ **script--部分** ~~~ var st = true; function Voice(){ if (st) { var speechRecognizer = api.require('speechRecognizer'); speechRecognizer.record({ vadbos: 5000, vadeos: 5000, rate: 16000, asrptt: 1, audioPath: 'fs://speechRecogniser/speech.mp3' }, function(ret, err) { if (ret.status) { $('textarea').val(ret.wordStr); // api.alert({ msg: ret.wordStr }); } else { api.alert({ msg: err.msg }); } }); $("#Voice").text("结束录音"); st = false; }else{ var speechRecognizer = api.require('speechRecognizer'); speechRecognizer.stopRecord(); $("#Voice").text("开始录音"); st = true; } } ~~~
';