TTS(TextToSpeech)将文本转为语音的简单使用
来源:互联网 发布:淘宝的钻石展位在哪里 编辑:程序博客网 时间:2024/05/06 11:56
private Button speechBtn; // 按钮控制开始朗读private TextView speechTxt; // 需要朗读的内容private TextToSpeech textToSpeech; // TTS对象 @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);speechBtn = (Button) findViewById(R.id.speechBtn); speechTxt = (TextView) findViewById(R.id.speechTxt); textToSpeech = new TextToSpeech(MainActivity.this, new TextToSpeech.OnInitListener() { @Override public void onInit(int status) { // TODO Auto-generated method stub if (status == TextToSpeech.SUCCESS) { int result = textToSpeech.setLanguage(Locale.US); if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) { Toast.makeText(MainActivity.this, "数据丢失或不支持", Toast.LENGTH_SHORT).show(); } } } });speechBtn.setOnClickListener(new OnClickListener() {@Override public void onClick(View v) { // TODO Auto-generated method stub if (textToSpeech != null && !textToSpeech.isSpeaking()) { textToSpeech.setPitch(1.5f);// 设置音调,值越大声音越尖(女生),值越小则变成男声,1.0是常规 textToSpeech.speak(speechTxt.getText().toString(), TextToSpeech.QUEUE_FLUSH, null); } } });}@Override protected void onStop() { super.onStop(); textToSpeech.stop(); // 不管是否正在朗读TTS都被打断 textToSpeech.shutdown(); // 关闭,释放资源 }
0 0
- TTS(TextToSpeech)将文本转为语音的简单使用
- TextToSpeech将文本转为语音的简单使用
- TextToSpeech将文本转为语音的简单使用
- Android中使用TTS(TextToSpeech)将文字转为语音
- TextToSpeech文本转为语音
- Android 文本转语音TextToSpeech (TTS)
- Android TTS文本转语音TextToSpeech
- Android TTS 中文 文字转语音 使用TextToSpeech Svox
- Android TTS 中文 文字转语音 使用TextToSpeech Svox
- Android TTS 中文 文字转语音 使用TextToSpeech Svox .
- 使用Svox实现中文转语音TextToSpeech(TTS)
- 使用Svox实现中文转语音TextToSpeech(TTS)
- Android中的TextToSpeech 将文本转换成语音的简单使用。
- 使用TextToSpeech语音读取
- Android TTS 英文或中文(要下载中文支持包)转语音 使用TextToSpeech
- Android TTS(TextToSpeech)语音输出与RecognizerIntent语音识别
- TTS---android 中TextToSpeech的用法
- 安卓文字转语音实例+代码+TextToSpeech的使用
- Save/Restore Your Activity State
- 大数相加相乘及阶乘
- fpga驱动ad9854重大bug——已解决!
- 安卓APP采用观察者模式实现检测版本更新
- HDU 4431 Mahjong 搜索 模拟
- TTS(TextToSpeech)将文本转为语音的简单使用
- 使用Sharedpreferences存取数据
- mac parallels 虚拟机连接网络
- 模仿jquery的注册事件方法
- 022给定一个字符串类型(string)表示的小数,打印出它的二进制表示(keep it up)
- JQuery
- 新博客计划
- 大富豪顾客发过火看大富豪
- 关于用三大框架写一个系统Dao层的设计