实现百度tts播音

这是一个关于如何在Android应用中使用百度的TTS(Text To Speech)SDK的示例代码。`OnlineTTSService`类实现了语音合成服务,而`MainActivity`类则展示了如何与服务交互,启动和停止语音合成。
摘要由CSDN通过智能技术生成

直接上代码

/*
 * File name: OnlineTTSService.java
 * 
 * Description: Online TTS service, use BAIDU SDK.
 *
 * Author: Theobald_wu, contact with wuqizhi@tydtech.com
 * 
 * Date: 2014-7-16   
 * 
 * Copyright (C) 2014 TYD Technology Co.,Ltd.
 * 
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.example.speack;


import android.app.Service;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.Messenger;
import android.os.RemoteException;
import android.util.Log;


import com.baidu.speechsynthesizer.SpeechSynthesizer;
import com.baidu.speechsynthesizer.SpeechSynthesizerListener;
import com.baidu.speechsynthesizer.publicutility.SpeechError;


public class asrservice extends Service implements
        SpeechSynthesizerListener {
    private static final String TAG = "[TYD_DEBUG]SpeechSynthesizerListener";
    private static final String APIKEY = "e5CgHToglONKKRzK0HBh4yG3";
    private static final String SECRETKEY = "Dpy7DYl6dbeEgGaAzKqhK4pMoxkNSPT7";
    private static final boolean DEBUG = true;
    private SpeechSynthesizer mTTS;
    public static final String ACTION_TTS_ONLINE = "android.intent.action.TTS.online";
    public static final String TTS_SPEAK_TEXT_KEY = "TTS.speak.text";
    public static final int TTS_SPEAK = 1;                  // speak
    public static final int TTS_CANCEL = 2;
    private Handler mHandler = new Handler() {
        public void dispatchMessage(Message msg) {
            if (DEBUG) {
               

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

安卓学习乐园

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值