企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# 语音识别模块--很轻松加载 > 加入第三方模块 ![](https://box.kancloud.cn/9bda32f099a45e54050a33b24df2b86d_509x170.png) **注:不需要配置任何文件** > 项目代码实例--语音输入文档--点击输入以及点击方法 **html--部分** ~~~ <div class="aui-btn aui-btn-primary aui-btn-block" tapmode onclick="Voice()" id="Voice">开始录音</div> ~~~ **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; } } ~~~