本文主要是介绍实现百度tts播音,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
直接上代码
/*
* 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) {
这篇关于实现百度tts播音的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!