更新记录

1.0.0(2026-01-25) 下载此版本

首个版本发布咯~


平台兼容性

uni-app(4.81)

Vue2 Vue3 Chrome Safari app-vue app-nvue Android iOS 鸿蒙 鸿蒙插件版本
× × × × - × × × 20 1.0.0
微信小程序 支付宝小程序 抖音小程序 百度小程序 快手小程序 京东小程序 鸿蒙元服务 QQ小程序 飞书小程序 小红书小程序 快应用-华为 快应用-联盟
× × × × × × × × × - × ×

鸿蒙TTS(Text To Speech)插件

简介

鸿蒙TTS (Text-To-Speech) 文字转语音插件,支持将文本转换为语音播放。

平台支持

  • ✅ HarmonyOS (使用 @kit.CoreSpeechKit)

API 说明

ttsInit(options)

初始化 TTS 引擎

参数说明:

参数 类型 必填 说明
rate Number 语速,范围 0.5-2.0,默认 1.0
pitch Number 音调,范围 0.5-2.0,默认 1.0
volume Number 音量,范围 0.0-1.0,默认 1.0
language String 语言,默认 'zh-CN'
success Function 成功回调
fail Function 失败回调
complete Function 完成回调

ttsSpeak(options)

朗读文本

参数说明:

参数 类型 必填 说明
text String 要朗读的文本
success Function 成功回调
fail Function 失败回调
complete Function 完成回调

ttsStop(options)

停止朗读

参数说明:

参数 类型 必填 说明
success Function 成功回调
fail Function 失败回调
complete Function 完成回调

ttsIsSpeaking()

检查是否正在朗读

返回值: Boolean

使用示例

import { ttsInit, ttsSpeak, ttsStop, ttsIsSpeaking } from '@/uni_modules/jack-tts'

// 1. 初始化
ttsInit({
  rate: 1.0,
  pitch: 1.0,
  volume: 1.0,
  language: 'zh-CN',
  success: (res) => {
    console.log('初始化成功', res)
  },
  fail: (err) => {
    console.error('初始化失败', err)
  }
})

// 2. 朗读文本
ttsSpeak({
  text: '你好,世界',
  success: (res) => {
    console.log('朗读成功', res)
  },
  fail: (err) => {
    console.error('朗读失败', err)
  }
})

// 3. 停止朗读
ttsStop({
  success: (res) => {
    console.log('停止成功', res)
  }
})

// 4. 检查是否正在朗读
const speaking = ttsIsSpeaking()
console.log('是否正在朗读:', speaking)

注意事项

  1. 使用前需要先调用 ttsInit 初始化
  2. 建议在页面 onUnload 时调用 ttsStop 停止朗读

隐私、权限声明

1. 本插件需要申请的系统权限列表:

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

插件不采集任何数据

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

许可协议

MIT协议