当前位置: 首页 > ai >正文

uni app 的app 端调用tts 进行文字转语音

本文使用了谷歌引擎。我的资源中已上传
speckutils.js 代码如下

// #ifdef APP
const SpeechTTS = uni.requireNativePlugin("MT-TTS-Speech");
// #endiffunction init(callback) {// #ifdef APPconsole.log('>> tts: init = 111');SpeechTTS.init((res) => {console.log(JSON.stringify(res))callback(true)console.log('>> tts: init success');});console.log('>> tts: init = 222');// #endif
}function speckAndShwoTast(text) {uni.showToast({title: text,icon: 'none'});// #ifdef APPconst res = SpeechTTS.speak({text: text});console.log('>> tts: play result = ' + res);// #endif
}function speckText(text) {// #ifdef APPconst res = SpeechTTS.speak({text: text});console.log('>> tts: play result = ' + res);// #endif
}function speckstop() {// #ifdef APPSpeechTTS.stop((res) => {console.log("speckstop", JSON.stringify(res))})// #endif
}function destroy() {// #ifdef APPconsole.log("销毁tts")SpeechTTS.destroy()// #endif
}module.exports = {init: init,speckAndShwoTast: speckAndShwoTast,speckText: speckText,destroy: destroy,};

使用

    import {
speckAndShwoTast
} from '../../utils/speckutils'

    speckAndShwoTast("请输入正确的用户名密码")

http://www.xdnf.cn/news/19832.html

相关文章:

  • GDAL 下载安装
  • C题目训练【三连击】
  • Vue3 + Ant Design Vue 实现多选下拉组件(支持分组、搜索与标签省略)
  • Ollama大模型 本地部署+使用教程
  • 【FastDDS】Layer DDS之Domain ( 05-Creating a DomainParticipant)
  • lesson53:CSS五种定位方式全解析:从基础到实战应用
  • GEO服务商推荐:移山科技以划时代高精尖技术引领AI搜索优化新纪元
  • C++ 5
  • 使用 Acme.sh 获取和管理免费 SSL 证书
  • 性能测试-jmeter8-脚本录制
  • 网络通信与协议栈 -- TCP协议与编程
  • [Java]PTA:求最大值
  • 财务文档处理优化:基于本地运行的PDF合并解决方案
  • 入行FPGA选择国企、私企还是外企?
  • Ansible高效管理大项目实战技巧
  • 【Python】数据可视化之点线图
  • Android 渐变背景色绘制
  • Git在idea中的实战使用经验(二)
  • 基于SpringBoot的宠物咖啡馆平台
  • 在DDPM(扩散模型)中,反向过程为什么不能和前向一样一步解决,另外实际公式推导时反向过程每一步都能得到一个预测值,为什么还要一步一步的推导?
  • 前端-Vue的生命周期和生命周期的四个阶段
  • 缠论笔线段画线,文华财经期货指标公式,好用的缠论指标源码
  • 特斯拉三代灵巧手:演进历程与核心供应链梳理
  • Spring AI调用sglang模型返回HTTP 400分析处理
  • 前端学习 10-2 :验证中的SV
  • Qt使用Maintenance添加、卸载组件(未完)
  • Java 技术支撑 AI 系统落地:从模型部署到安全合规的企业级解决方案(四)
  • 嵌入式学习 51单片机(2)
  • 【C++】string类完全解析与实战指南
  • centos 压缩命令