更新记录
1.0.0(2025-03-31)
百度语音-鸿蒙版
平台兼容性
App |
快应用 |
微信小程序 |
支付宝小程序 |
百度小程序 |
字节小程序 |
QQ小程序 |
HBuilderX 4.43,Android:不确定,iOS:不确定,HarmonyNext:支持 |
× |
× |
× |
× |
× |
× |
钉钉小程序 |
快手小程序 |
飞书小程序 |
京东小程序 |
鸿蒙元服务 |
× |
× |
× |
× |
× |
H5-Safari |
Android Browser |
微信浏览器(Android) |
QQ浏览器(Android) |
Chrome |
IE |
Edge |
Firefox |
PC-Safari |
× |
× |
× |
× |
× |
× |
× |
× |
× |
<template>
<!-- #ifdef APP -->
<scroll-view style="flex: 1">
<!-- #endif -->
<view class="page">
<button @tap="handleInitSDKBtn">initSDK</button>
<button @tap="handleStartBtn">Start</button>
<button @tap="handleEndBtn">End</button>
<button @tap="handleCancelBtn">Cancel</button>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script>
// #ifdef APP-HARMONY
import { hmInitAsrSDK, hmStartAsr, hmEndAsr, hmCancelAsr } from '@/uni_modules/xb-baiduasr';
// #endif
export default {
data() {
return {};
},
methods: {
handleInitSDKBtn() {
// #ifdef APP-HARMONY
hmInitAsrSDK(
() => {
console.log('百度语音初始化成功');
},
(err) => {
console.log('百度语音初始化失败' + JSON.string(err));
}
);
// #endif
},
handleStartBtn() {
// #ifdef APP-HARMONY
hmStartAsr(2, 'you apikey', 'you sk', this.onStart, this.onRecognizing, this.onRecognition, this.onEnd);
// #endif
},
onStart() {
console.log('开始识别');
},
onRecognizing(res) {
console.log('识别中:' + JSON.stringify(res));
},
onRecognition(res) {
console.log('开始结果' + JSON.stringify(res));
},
onEnd() {
console.log('开始结束');
},
handleEndBtn() {
// #ifdef APP-HARMONY
hmEndAsr();
// #endif
},
handleCancelBtn() {
// #ifdef APP-HARMONY
hmCancelAsr();
// #endif
}
}
};
</script>
<style></style>