- 浏览: 229233 次
- 性别:
- 来自: 广州
最新评论
-
Janne:
你好 有源代码?可以发到我的邮箱里学学吗?2731049993 ...
achartengine画出动态折线图的效果 -
anbo724:
我的邮箱 anbo724@gmail.com谢谢@
achartengine画出动态折线图的效果 -
anbo724:
你好 请问有源码没《?谢谢
achartengine画出动态折线图的效果 -
weiday123:
额,觉得这个会不会占堆内存?
AdapterView、Adapter优化 -
wen742538485:
为什么没有呢?权限没加还是发创建了给你删了再想创建?是不允许重 ...
Android中为你的应用程序添加桌面快捷方式
Android 通过手说tts中文语音包实现中文朗读
关于手说tts中文语音包的详细资料可以查看官网 http://shoushuo.com/index.html
手说TTS,是Android平台下的中文语音引擎,提供了中文文本到语音的转换。
使用手说TTS进行中文文本的朗读,包括中文简繁体、阿拉伯数字、英文字母及一些符号的混读。并且处理了中文的多音字和音调转换等问题。
开发人员可以使用手说TTS来开发Android平台下需要中文语音的应用程序。
开发准备:
第一步:安装手说TTS安装包
从官网 http://shoushuo.com/sstts.html 下载手说TTS安装包:ShoushuoTTS.apk 。
安装到真实手机或者手机模拟器中。
第二步:下载手说TTS客户类库包
下载手说TTS客户类库包:shoushuotts.jar 。
将该jar文件引入到你的应用中。
第二步:demo实现
xml文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<EditText
android:id="@+id/edtSpeectText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="太阳从东边升起,慢慢的露出红彤彤的笑脸。"
/>
<Button
android:id="@+id/btnSpeechGo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="开始朗读"
android:onClick="speechText"
/>
</LinearLayout>
java代码:
Java代码
package com.zhouzijing.android.demo;
import com.shoushuo.android.tts.ITts;
import com.shoushuo.android.tts.ITtsCallback;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.RemoteException;
import android.speech.tts.TextToSpeech;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class SpeechActivity extends Activity {
private EditText edtSpeectText;
private Button btnSpeechGo;
private Context context;
private ITts ttsService;
private boolean ttsBound;
/**
* 定义Handler.
*/
private final Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
Toast.makeText(context, " 我的话说完了 ", Toast.LENGTH_SHORT).show();
btnSpeechGo.setEnabled(true);
}
};
/**
* 回调参数.
*/
private final ITtsCallback ttsCallback = new ITtsCallback.Stub() {
//朗读完毕.
@Override
public void speakCompleted() throws RemoteException {
handler.sendEmptyMessage(0);
}
};
/**
* tts服务连接.
*/
private final ServiceConnection ttsConnection = new ServiceConnection() {
@Override
public void onServiceDisconnected(ComponentName arg0) {
try {
//注册回调参数
ttsService.unregisterCallback(ttsCallback);
} catch (RemoteException e) {
e.printStackTrace();
}
ttsService = null;
ttsBound = false;
}
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
ttsService = ITts.Stub.asInterface(service);
ttsBound = true;
try {
//tts服务初始化
ttsService.initialize();
//撤销回调参数.
ttsService.registerCallback(ttsCallback);
} catch (RemoteException e) {
}
}
};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.speech_text);
context = this;
edtSpeectText = (EditText) findViewById(R.id.edtSpeectText);
btnSpeechGo = (Button) findViewById(R.id.btnSpeechGo);
}
/**
* 按钮:朗读.
*
* @param v
*/
public void speechText(View v) {
v.setEnabled(false);
try {
ttsService.speak(edtSpeectText.getText().toString(),
TextToSpeech.QUEUE_FLUSH);
} catch (RemoteException e) {
e.printStackTrace();
}
}
@Override
protected void onDestroy() {
if (ttsBound) {
ttsBound = false;
//撤销tts服务
this.unbindService(ttsConnection);
}
super.onDestroy();
}
@Override
protected void onStart() {
super.onStart();
if (!ttsBound) {
String actionName = "com.shoushuo.android.tts.intent.action.InvokeTts";
Intent intent = new Intent(actionName);
//绑定tts服务
this.bindService(intent, ttsConnection, Context.BIND_AUTO_CREATE);
}
}
}
关于手说tts中文语音包的详细资料可以查看官网 http://shoushuo.com/index.html
手说TTS,是Android平台下的中文语音引擎,提供了中文文本到语音的转换。
使用手说TTS进行中文文本的朗读,包括中文简繁体、阿拉伯数字、英文字母及一些符号的混读。并且处理了中文的多音字和音调转换等问题。
开发人员可以使用手说TTS来开发Android平台下需要中文语音的应用程序。
开发准备:
第一步:安装手说TTS安装包
从官网 http://shoushuo.com/sstts.html 下载手说TTS安装包:ShoushuoTTS.apk 。
安装到真实手机或者手机模拟器中。
第二步:下载手说TTS客户类库包
下载手说TTS客户类库包:shoushuotts.jar 。
将该jar文件引入到你的应用中。
第二步:demo实现
xml文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<EditText
android:id="@+id/edtSpeectText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="太阳从东边升起,慢慢的露出红彤彤的笑脸。"
/>
<Button
android:id="@+id/btnSpeechGo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="开始朗读"
android:onClick="speechText"
/>
</LinearLayout>
java代码:
Java代码
package com.zhouzijing.android.demo;
import com.shoushuo.android.tts.ITts;
import com.shoushuo.android.tts.ITtsCallback;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.RemoteException;
import android.speech.tts.TextToSpeech;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class SpeechActivity extends Activity {
private EditText edtSpeectText;
private Button btnSpeechGo;
private Context context;
private ITts ttsService;
private boolean ttsBound;
/**
* 定义Handler.
*/
private final Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
Toast.makeText(context, " 我的话说完了 ", Toast.LENGTH_SHORT).show();
btnSpeechGo.setEnabled(true);
}
};
/**
* 回调参数.
*/
private final ITtsCallback ttsCallback = new ITtsCallback.Stub() {
//朗读完毕.
@Override
public void speakCompleted() throws RemoteException {
handler.sendEmptyMessage(0);
}
};
/**
* tts服务连接.
*/
private final ServiceConnection ttsConnection = new ServiceConnection() {
@Override
public void onServiceDisconnected(ComponentName arg0) {
try {
//注册回调参数
ttsService.unregisterCallback(ttsCallback);
} catch (RemoteException e) {
e.printStackTrace();
}
ttsService = null;
ttsBound = false;
}
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
ttsService = ITts.Stub.asInterface(service);
ttsBound = true;
try {
//tts服务初始化
ttsService.initialize();
//撤销回调参数.
ttsService.registerCallback(ttsCallback);
} catch (RemoteException e) {
}
}
};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.speech_text);
context = this;
edtSpeectText = (EditText) findViewById(R.id.edtSpeectText);
btnSpeechGo = (Button) findViewById(R.id.btnSpeechGo);
}
/**
* 按钮:朗读.
*
* @param v
*/
public void speechText(View v) {
v.setEnabled(false);
try {
ttsService.speak(edtSpeectText.getText().toString(),
TextToSpeech.QUEUE_FLUSH);
} catch (RemoteException e) {
e.printStackTrace();
}
}
@Override
protected void onDestroy() {
if (ttsBound) {
ttsBound = false;
//撤销tts服务
this.unbindService(ttsConnection);
}
super.onDestroy();
}
@Override
protected void onStart() {
super.onStart();
if (!ttsBound) {
String actionName = "com.shoushuo.android.tts.intent.action.InvokeTts";
Intent intent = new Intent(actionName);
//绑定tts服务
this.bindService(intent, ttsConnection, Context.BIND_AUTO_CREATE);
}
}
}
发表评论
-
Android Tween动画之RotateAnimation实现图片不停旋转
2012-11-26 22:38 1042本文主要介绍Android中如何使用rotate实现图片不停旋 ... -
Android实现widget定时更新
2012-11-04 20:20 887在开发Android的widget时,第一个需要解决的问题就是 ... -
来自腾讯、谷歌、百度等名企的精选面试五十题
2012-10-07 23:08 907http://www.apkway.com/thread-90 ... -
Android 中Parcelable的作用
2012-09-24 09:53 840android提供了一种新的类型:Parcel。本类被用作封装 ... -
[Android算法] 【eoeAndroid索引】史上最牛最全android开发知识汇总
2012-09-13 09:33 1096http://www.eoeandroid.com/threa ... -
安卓航班推荐70个具有商业实战性的精品Android源码
2012-08-01 00:00 919http://www.apkway.com/thread-58 ... -
Android测试教程汇总
2012-08-02 14:51 1070http://www.apkway.com/thread-67 ... -
Service 与 Thread 的区别
2012-07-26 00:10 883Service 与 Thread 的区别 很多时候,你可能 ... -
android 使用百度地图画轨迹
2012-07-26 00:08 2586import android.content.Context ... -
android百度地图半径画圆
2012-07-26 00:07 2717Java代码 import android.content ... -
Android下获取开机时间
2012-07-26 00:05 1300我的思路是:程序里注册个广播接收器,接收开机启动的广播,当程序 ... -
android 高仿【优酷】圆盘旋转菜单 的实现
2012-07-26 00:03 1340MyAnimation.java Java代码 pack ... -
android 3D 转盘效果(附源码)
2012-07-25 23:41 1782一个仿3D的转盘效果,有倒影特效,旋转图标还可自动放大缩小。由 ... -
Android Thread
2012-07-23 10:47 1015创建新线程的常用方式: 1. 直接使用Thread创建 ... -
Android 使用HTTPClient调用Web请求(查询手机号码区域)
2012-07-21 00:33 1202Android通过Apache HttpClient调用网上提 ... -
Android+struts2+JSON方式的手机开发
2012-07-21 00:14 1141http://topmanopensource.iteye.c ... -
android九宫格实现
2012-07-21 00:03 943android九宫格实现,开始以为很复杂,其实只要知道了如何布 ... -
Android ListView圆角实现
2012-07-20 23:59 1182在android上开发项目,如 ... -
Android 将一个Activity转化为View显示出来
2012-07-19 10:27 2067最近看到好多opengl牛人写了些立方体,卷页之类的华丽的代码 ... -
Android EditText 为空提示 密码隐藏
2012-07-17 23:39 1104EditText为空时提示方法: 1.xml文件中设置,如: ...
相关推荐
android下实现对文本的语音朗读,TTS技术,支持中文朗读。Android SDK 4.04下测试通过。 附件包含测试源代码及语音库文件 这是语音合成测试工程,如果需要朗读中文请安装中文引擎。我采用的是讯飞语音库,手机版本...
科大讯飞TTS离线语音包,供科大讯飞Android TTS引擎使用
用于android开发语音识别TTS的jar包。支持朗读中文。为在google无法下载提供方便!
包含两款支持安卓(Android)离线语音合成(朗读)的演示App源码,采用塘上科技语音合成SDK,支持变声,变音高和语速,无需联网可节省流量。项目请用Eclipse+ADT进行编译,ADT需要v21.1.0-569685或更新的版本。 最新版...
度秘语音引擎,3.0版本,android系统安装后可以选择引擎进行TTS转换。
一个能说中文tts jar包,辅助开发者开发。Android 从1.6 版本开始支持Text To Speech ,使用的是Pico 语音合成引擎,但是只支持 English 、 French 、 German...因此使用 Android 默认的 TTS Engine 是没法朗读中文的。
8.5 自动朗读(TTS) 347 8.6 本章小结 350 第9章 使用ContentProvider实现 第9章 数据共享 351 9.1 数据共享标准: ContentProvider简介 352 9.1.1 ContentProvider简介 352 9.1.2 Uri简介 353 ...
8.5 自动朗读(TTS) 347 8.6 本章小结 350 第9章 使用ContentProvider实现 第9章 数据共享 351 9.1 数据共享标准: ContentProvider简介 352 9.1.1 ContentProvider简介 352 9.1.2 Uri简介 353 9.1.3 使用...
8.5 自动朗读(TTS) 347 8.6 本章小结 350 第9章 使用ContentProvider实现 第9章 数据共享 351 9.1 数据共享标准: ContentProvider简介 352 9.1.1 ContentProvider简介 352 9.1.2 Uri简介 353 9.1.3 使用...
在默认情况下,语音识别的语言为英文,你可以通过长按语音按钮切换语言,当然,你要是不嫌麻烦,在设置中也能进行更改。金山词霸给出的识别结果有时不仅仅只有一个备选项,而相 对来说,字母拼写的方式更加准确。 ...