更新记录
1.0(2026-02-09) 下载此版本
init
平台兼容性
uni-app
| Vue2 | Vue3 | Chrome | Safari | app-vue | app-nvue | Android | iOS | 鸿蒙 |
|---|---|---|---|---|---|---|---|---|
| - | - | - | - | - | - | - | × | × |
| 微信小程序 | 支付宝小程序 | 抖音小程序 | 百度小程序 | 快手小程序 | 京东小程序 | 鸿蒙元服务 | QQ小程序 | 飞书小程序 | 小红书小程序 | 快应用-华为 | 快应用-联盟 |
|---|---|---|---|---|---|---|---|---|---|---|---|
| - | - | - | - | - | - | - | - | - | - | - | - |
参考 https://cloud.baidu.com/article/3896533
initTTS 初始化
SpeakTTS 播报
全部代码:
let TextToSpeech
let tts
export default class TTS {
static initTTS() {
const main = plus.android.runtimeMainActivity();
TextToSpeech = plus.android.importClass('android.speech.tts.TextToSpeech');
const Context = plus.android.importClass('android.content.Context');
tts = new TextToSpeech(
main,
new TextToSpeech.OnInitListener({
onInit: function(status) {
if (status === TextToSpeech.SUCCESS) {
const result = tts.setLanguage(plus.android.invoke('java.util.Locale', 'US'));
if (result === TextToSpeech.LANG_MISSING_DATA || result === TextToSpeech.LANG_NOT_SUPPORTED) {
console.log('语言包未安装');
}
}
}
}),
null
);
}
static SpeakTTS(text, pitch = 1.0, rate = 1.0) {
if (!tts) {
this.initTTS();
}
tts.setPitch(pitch);
tts.setSpeechRate(rate);
tts.speak(text, TextToSpeech.QUEUE_FLUSH, (e) => {
console.log(e);
}, (e) => {
console.log(e);
});
}
}
兼容性什么的都没试,需要自行测试
需要配合中文tts引擎 低版本安卓需要安装 讯飞语记 或其他中文引擎 且需要在设置中修改为中文引擎 自带中文引擎的实测一加ace(安卓15)不需要
小白 尝试一下发布插件 设置的价格是无意义的

收藏人数:
下载插件并导入HBuilderX
下载插件ZIP
赞赏(0)
下载 2
赞赏 0
下载 11220650
赞赏 1858
赞赏
京公网安备:11010802035340号