您的位置:首页 > 移动开发 > Android开发

Android TTS 中文 文字转语音 使用TextToSpeech Svox

2012-03-31 17:35 1456 查看
Android默认没有安装TTS数据包,无法文字转语音,而在设置里推荐的语音包是Pico TTS,并不支持中文,如果需要读中文,需要下载另外的第三方语音包,如:eSpeak,Svox,个人建议Svox,eSpeak非常生硬,而且很多汉字都读不出,不支持中英文混读(英文当拼音读)。下载链接自己Google下吧,很多软件市场都有下载。下载安装后打开设置-语音输入和输出-文字转语音设置,勾选Svox Classic TTS,语言选择中文或广东话(Svox安装后还要下载安装相应的语言包的,类似插件)。接下来代码就简单了,关键的就两三行:

package com.pocketdigi;
 
import android.app.Activity;
import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
 
public class TTSActivity extends Activity {
/** Called when the activity is first created. */
TextToSpeech tts;
Button btn;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
btn=(Button)findViewById(R.id.btn);
tts = new TextToSpeech(this, null);
//实例化
btn.setOnClickListener(new OnClickListener(){
 
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
tts.speak("测试一下", TextToSpeech.QUEUE_FLUSH, null);
//语音输出
}});
 
}
}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

用Svox,效果还不错。

2011年7月21日加注:

貌似使用Svox后,isLanguageAvailable就不能检测语言是否支持了,而Pico TTS是可以的

Svox Classic TTS(Svox中文语音插件)v2.0.4 告别英文语音

public class TTSActivity extends Activity {
/** Called when the activity is first created. */
TextToSpeech tts;
Button btn;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
btn=(Button)findViewById(R.id.btn);
tts = new TextToSpeech(this, null);
//实例化
btn.setOnClickListener(new OnClickListener(){
 
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
tts.speak("测试一下", TextToSpeech.QUEUE_FLUSH, null);
//语音输出
}});
 
}
}

Svox Classic TTS

软件大小:2.22M

软件版本:2.0.4

开发作者:SVOX Mobile Voices

适用固件:2.1,2.2,2.3.1,2.3.3,

适用分辨率:240x320 240x400 240x432 320x480 360x640 480x800 480x848 480x854 600x1024 600x800 720x1280

Svox Classic TTS(Svox语音插件) v2.0.4;

一款好用的语音插件,支持多种语言阅读。第三方语音识别软件可用,例如:超级短信Handcent Sms等。需下载语音包才可使用,现提供已付费中文普通话语音包和粤语语音包。



2011-3-30 08:06 上传
下载附件(9.67 KB)



2011-3-30 08:06 上传
下载附件(5.89 KB)



2011-3-30 08:06 上传
下载附件(6.79 KB)



2011-3-30 08:06 上传
下载附件(4.74 KB)

软件下载:

http://u.115.com/file/f5b8d8f669#

com.svox.classic.apk

语音包下载地址:

中文普通话语音包:http://www.nduoa.com/web/soft/show/id/4954

粤语语音包:http://www.nduoa.com/web/soft/show/id/4955

使用教程:
Svox Classic TTS(Svox中文语音插件)详细安装方法,绝对可用

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息