更新记录
1.0.1(2025-06-10)
优化
1.0.0(2025-06-10)
初始化
平台兼容性
uni-app
Vue2 |
Vue3 |
Chrome |
Safari |
app-vue |
app-nvue |
Android |
iOS |
鸿蒙 |
√ |
√ |
- |
- |
- |
- |
4.4 |
12 |
- |
微信小程序 |
支付宝小程序 |
抖音小程序 |
百度小程序 |
快手小程序 |
京东小程序 |
鸿蒙元服务 |
QQ小程序 |
飞书小程序 |
快应用-华为 |
快应用-联盟 |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
uni-app x
Chrome |
Safari |
Android |
iOS |
鸿蒙 |
微信小程序 |
- |
- |
5.0 |
12 |
- |
- |
lq-xunfei
讯飞SparkChain sdk 安卓/ios
uniappx
<template>
<view style="display: flex;flex-direction: column;">
<input v-model="tts_msg" style="width: 100%;"/>
<button type="primary" style="margin: 10rpx;" @click="onClick(0)">语音合成</button>
<button type="primary" style="margin: 10rpx;" @click="onClick(1)">在线翻译</button>
<button type="primary" style="margin: 10rpx;" @click="onClick(2)">开始语音听写</button>
<button type="primary" style="margin: 10rpx;" @click="onClick(3)">取消语音听写</button>
<button type="primary" style="margin: 10rpx;" @click="onClick(4)">实时语音转写</button>
<button type="primary" style="margin: 10rpx;" @click="onClick(5)">停止语音转写</button>
<button type="primary" style="margin: 10rpx;" @click="onClick(6)">文本交互</button>
<button type="primary" style="margin: 10rpx;" @click="onClick(7)">录音文件转写</button>
<text>{{show_msg}}</text>
</view>
</template>
<script>
import { initXunFeiSDKInit,onStartITS, ITSPara,ITSBack,ASRPara,ASRBack,onStartASR,stopASR,onStartRTASR,ParaRTASR,RTASRBack,stopRTASR,TTSPara,onStartTTS,stopVoice,IIMPara,IIMBack,onStatrIIM,onStartRAASR,stopRAASR,RAASRPara,RAASRBack} from "@/uni_modules/lq-xunfei"
export default {
data() {
return {
tts_msg:"语音合成测试",
show_msg:"",
title: 'Hello'
}
},
onLoad() {
var b= initXunFeiSDKInit("xxxxx",
"xxxxxxxxxxxxxxxxxxxxxxxxxxx",
"xxxxxxxxxxxxxxxxxxxxxxxxxx")
console.log(b);
},
methods: {
onClick(num:number){
var that=this;
if(num==0){
onStartTTS({
text:that.tts_msg,
micPlay:true,
callback:function(res:number){
console.log(res);
that.show_msg=JSON.stringify(res)
}
} as TTSPara)
}else if(num==1){
onStartITS({
transText:that.tts_msg,
fromlanguage:"cn",
tolanguage:"en",
callback:function(p:ITSBack){
console.log(p);
that.show_msg=JSON.stringify(p)
}
} as ITSPara)
}else if(num==2){
onStartASR({
mode:0,
callback: (res:ASRBack) => {
that.show_msg=JSON.stringify(res)
console.log(res);
}
} as ASRPara)
}else if(num==3){
stopASR(false);
}else if(num==4){
onStartRTASR({
key:"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
mode:0,
lang:"cn",
targetLang:"en",
callback:function(p:RTASRBack){
that.show_msg=JSON.stringify(p)
}
} as ParaRTASR)
}else if(num==5){
stopRTASR(false);
}else if(num==6){
onStatrIIM({
text:"讯飞",
callback: (res:IIMBack) => {
that.show_msg=JSON.stringify(res);
}
} as IIMPara)
}
}
}
}
</script>
uniapp
<template>
<view style="display: flex;flex-direction: column;">
<input v-model="tts_msg" style="width: 100%;"/>
<button type="primary" style="margin: 10rpx;" @click="onClick(0)">语音合成</button>
<button type="primary" style="margin: 10rpx;" @click="onClick(1)">在线翻译</button>
<button type="primary" style="margin: 10rpx;" @click="onClick(2)">开始语音听写</button>
<button type="primary" style="margin: 10rpx;" @click="onClick(3)">取消语音听写</button>
<button type="primary" style="margin: 10rpx;" @click="onClick(4)">实时语音转写</button>
<button type="primary" style="margin: 10rpx;" @click="onClick(5)">停止语音转写</button>
<button type="primary" style="margin: 10rpx;" @click="onClick(6)">文本交互</button>
<button type="primary" style="margin: 10rpx;" @click="onClick(7)">录音文件转写</button>
<text>{{show_msg}}</text>
</view>
</template>
<script>
import { initXunFeiSDKInit,onStartITS, ITSPara,ITSBack,ASRPara,ASRBack,onStartASR,stopASR,onStartRTASR,ParaRTASR,RTASRBack,stopRTASR,TTSPara,onStartTTS,stopVoice,IIMPara,IIMBack,onStatrIIM,onStartRAASR,stopRAASR,RAASRPara,RAASRBack} from "@/uni_modules/lq-xunfei"
export default {
data() {
return {
tts_msg:"语音合成测试",
show_msg:"",
title: 'Hello'
}
},
onLoad() {
var b= initXunFeiSDKInit("xxxxx",
"xxxxxxxxxxxxxxxxxxxxxxxxxxx",
"xxxxxxxxxxxxxxxxxxxxxxxxxx")
console.log(b);
},
methods: {
onClick(num){
var that=this;
if(num==0){
onStartTTS({
text:that.tts_msg,
micPlay:true,
callback:function(res){
console.log(res);
that.show_msg=JSON.stringify(res)
}
})
}else if(num==1){
onStartITS({
transText:that.tts_msg,
fromlanguage:"cn",
tolanguage:"en",
callback:function(p){
console.log(p);
that.show_msg=JSON.stringify(p)
}
})
}else if(num==2){
onStartASR({
mode:0,
callback: (res) => {
that.show_msg=JSON.stringify(res)
console.log(res);
}
} )
}else if(num==3){
stopASR(false);
}else if(num==4){
onStartRTASR({
key:"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
mode:0,
lang:"cn",
targetLang:"en",
callback:function(p){
that.show_msg=JSON.stringify(p)
}
} )
}else if(num==5){
stopRTASR(false);
}else if(num==6){
onStatrIIM({
text:"讯飞",
callback: (res) => {
that.show_msg=JSON.stringify(res);
}
})
}
}
}
}
</script>
export type ITSPara={
transType?:number,
transText:string,
fromlanguage?:string,
tolanguage?:string,
callback:(p:ITSBack)=>void
}
export type ITSBack={
result:boolean,
srcText?:string,
dstText?:string,
status?:number,
sid?:string,
from?:string,
to?:string,
}
export type ASRPara = {
mode?:number,
domain?:string,
language?:string,
useErji?:boolean,
filePath?:string,
callback:(back:ASRBack)=>void;
}
export type ASRBack={
result:boolean,
begin?:number,
end?:number,
status?:number,
resultData?:string,
sid?:string,
}
export type ParaRTASR={
key:string,
pd?:string,
roleType?:number,
useErji?:boolean,
mode?:number,
lang?:string,
punc?:string,
targetLang?:string,
filePath?:string,
callback:(p:RTASRBack)=>void;
}
var asrFinalResult="";
var transFinalResult="";
export type RTASRBack={
result:boolean,
data?:string,
rawResult?:string,
status?:number,
sid?:string,
src?:string,
dst?:string,
transStatus?:number,
isAsrFinalResultEnd?:boolean,
asrFinalResultData?:string,
isTransFinalResultEnd?:boolean
transFinalResult?:string,
}
开发文档
UTS 语法
UTS API插件
UTS uni-app兼容模式组件
UTS 标准模式组件
Hello UTS