更新记录
1.0.0(2025-08-24) 下载此版本
yao-iFLYTEK-identify
科大讯飞语音听写
平台兼容性
uni-app(4.07)
Vue2 | Vue3 | Chrome | Safari | app-vue | app-nvue | Android | iOS | 鸿蒙 |
---|---|---|---|---|---|---|---|---|
√ | √ | √ | √ | √ | × | √ | √ | × |
微信小程序 | 支付宝小程序 | 抖音小程序 | 百度小程序 | 快手小程序 | 京东小程序 | 鸿蒙元服务 | QQ小程序 | 飞书小程序 | 快应用-华为 | 快应用-联盟 |
---|---|---|---|---|---|---|---|---|---|---|
× | × | × | × | × | × | × | × | × | × | × |
yao-iFLYTEK-identify
配置
需要将模块下uni_modules/yao-iFLYTEK-identify的dist复制到static目录下面 或者 将uni_modules/yao-iFLYTEK-identify/dist目录的配置文件放到static/dist目录下面
如果项目没有crypto-js需要安装crypto-js
npm i crypto-js
代码示例
<template>
<view class="content">
<view @click="onStart">开始说话</view>
<view @click="onStop">停止说话</view>
<view style="width:90%;margin:0 auto;;">
{{text}}
</view>
<yao-iFLYTEK-identify
ref="iFLYTEKIdentify"
:option="iFLYTEKOption"
@change="onIFLYTEKChange"
@outcome="onOutcome"
></yao-iFLYTEK-identify>
</view>
</template>
<script>
export default {
data() {
return {
text:"",
iFLYTEKOption:{
APPID:"",
APISecret:"",
APIKey:"",
LANGUAGE:"zh_cn", //识别语言
vad_eos:1000, //即静默多长时间后引擎认为音频结束。当前设置1秒
}
}
},
onLoad() {
},
methods: {
onStart(){
this.$refs.iFLYTEKIdentify.start();
},
onStop(){
this.$refs.iFLYTEKIdentify.stop();
},
//当前录音状态
onIFLYTEKChange(e){
console.log(e);
if(e.status == "STOP"){
//录音已关闭
}else if(e.status == "START"){
//开始录音
}else if(e.status == "ERROR"){
//连接发生错误
}
},
//识别结果
onOutcome(literals){
this.text=literals;
}
}
}
</script>