TextToSpeech之阅读文字
2015-09-21 15:58
369 查看
创建阅读类
在使用的时候直接调用相应的方法即可实现阅读。
/** * Created by RongGuang on 2014-11-21. * 中文朗读 */ public class ChineseToSpeech { private TextToSpeech textToSpeech; public ChineseToSpeech() { this.textToSpeech = new TextToSpeech(Application.getContext(), new TextToSpeech.OnInitListener() { @Override public void onInit(int status) { if (status == TextToSpeech.SUCCESS) { int result = textToSpeech.setLanguage(Locale.CHINA); if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) { new CoolToast(Application.getContext()).show("不支持朗读功能"); } } } }); } public void speech(String text) { textToSpeech.speak(text, TextToSpeech.QUEUE_FLUSH, null); } public void destroy() { if (textToSpeech != null) { textToSpeech.stop(); textToSpeech.shutdown(); } } }
在使用的时候直接调用相应的方法即可实现阅读。
相关文章推荐
- 框架学习八:二维码(Zxing)
- oracle10G 数据泵技术
- spark作业调度
- @property
- Java中如何实现时间的加减
- Torch基础学习(一)
- Boost和标准库中正则表达式的使用
- sql去重查询
- hdu 1257 最少拦截系统 (贪心)
- 添加的千分的分隔符
- Tomcat下部署多个项目
- ocp-v13-683
- 添加千分的分隔符
- git 命令学习及更新
- 提高网页性能的九大技巧
- JAVA自带监控工具的介绍
- NET编程简易生成用友财务软件的财务接口数据
- Spring with Hibernate persistence and transactions example
- Android中常见的像素单位
- ubuntu 环境变量改错导致所有命令用不了