<commit_before>package com.sunteam.ebook.util;

import java.util.Locale;

import com.iflytek.business.speech.SpeechIntent;
import com.iflytek.business.speech.SpeechServiceUtil;
import com.iflytek.business.speech.SpeechServiceUtil.ISpeechInitListener;
import com.iflytek.business.speech.SynthesizerListener;
import com.iflytek.business.speech.TextToSpeech;
import com.sunteam.ebook.R;
import com.sunteam.ebook.entity.TTSRole;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.res.Resources;
import android.os.Bundle;
import android.os.Environment;
import android.os.RemoteException;
import android.util.Log;

/**
 * TTS工具类。
 * 
 * @author wzp
 */
public class TTSUtils
{
    private static final String TAG = "TTSUtils";
	private static TTSUtils instance = null;
	private Context mContext;
	private SpeechServiceUtil mService;
	private Intent ttsParamsIntent;	//合成参数设置Intent
    private SharedPreferences mSharedPreferences;
    private String resType = "";
	private boolean isSuccess = false;
	private OnTTSListener mOnTTSListener = null;
	private SpeakStatus mSpeakStatus = SpeakStatus.STOP;
	private SpeakForm mSpeakForm = SpeakForm.TIPS;
	
	private static final int[] mRoleCn = {
		3,	//晓燕
		4,	//晓峰
		15,	//晓美
		
		51,	//许久
		52,	//许多
		53,	//晓萍
		54,	//唐老鸭
		55,	//许小宝
		56,	//大龙
		
		7,	//楠楠
		9,	//嘉嘉
		11,	//小倩
		14,	//晓蓉
		22,	//晓琳
		24,	//小强
		25,	//小坤
	};	//中文发音人
	
	private static final int[] mRoleEn = {
		20,	//凯瑟琳
		
		3,	//晓燕
		4,	//晓峰
		15,	//晓美
		
		51,	//许久
		52,	//许多
		53,	//晓萍
		54,	//唐老鸭
		55,	//许小宝
		56,	//大龙
	};	//英文发音人
	
	private static final int[] mEffect = {
		0,	//原声	
		2,	//回声
		3,	//机器人
		7,	//阴阳怪气
	};	//音效
	
	public interface OnTTSListener 
	{
		public void onSpeakCompleted();		//朗读完成
		public void onSpeakError();			//朗读错误
	}
	
	public enum SpeakForm
	{
		TIPS,	//提示
		CONTENT,//内容
	}	//朗读形式
	
	public enum SpeakStatus
	{
		STOP, 	//停止
		PAUSE,	//暂停
		SPEAK,	//朗读
	}	//朗读状态
	
	//设置监听器
	public void OnTTSListener( OnTTSListener listener )
	{
		mOnTTSListener = listener;
	}
	
	//得到当前TTS状态
	public SpeakStatus getSpeakStatus()
	{
		return	mSpeakStatus;
	}
	
	public static TTSUtils getInstance()
	{
		if( null == instance )
		{
			instance = new TTSUtils();
		}
		
		return instance;
	}
	
	//得到TTS对象
	public SpeechServiceUtil getTextToSpeech()
	{
		return	mService;
	}
	
	//初始化
	public void init( Context context )
	{
		mContext = context.getApplicationContext();
		
		mSharedPreferences = mContext.getSharedPreferences(EbookConstants.TTS_SETTINGS, Activity.MODE_PRIVATE);
		resType = mSharedPreferences.getString("tts_resource", "0");
        // 合成对象初始化
        ttsParamsIntent = new Intent();
        Intent serviceIntent = new Intent();
        serviceIntent.putExtra(SpeechIntent.SERVICE_LOG_ENABLE, true);
        mService = new SpeechServiceUtil(mContext, mInitListener, serviceIntent);
	}
	
	//销毁
	public void destroy()
	{
		if(mService != null)
		{
			mService.destroy();
			mService = null;
		}
	}

	//是否初始化成功
	public boolean isSuccess()
	{
		return	isSuccess;
	}<commit_msg>去除警告信息。<commit_after>package com.sunteam.ebook.util;

import com.iflytek.business.speech.SpeechIntent;
import com.iflytek.business.speech.SpeechServiceUtil;
import com.iflytek.business.speech.SpeechServiceUtil.ISpeechInitListener;
import com.iflytek.business.speech.SynthesizerListener;
import com.iflytek.business.speech.TextToSpeech;
import com.sunteam.ebook.R;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.res.Resources;
import android.os.Environment;
import android.os.RemoteException;
import android.util.Log;

/**
 * TTS工具类。
 * 
 * @author wzp
 */
public class TTSUtils
{
    private static final String TAG = "TTSUtils";
	private static TTSUtils instance = null;
	private Context mContext;
	private SpeechServiceUtil mService;
	private Intent ttsParamsIntent;	//合成参数设置Intent
    private SharedPreferences mSharedPreferences;
	private boolean isSuccess = false;
	private OnTTSListener mOnTTSListener = null;
	private SpeakStatus mSpeakStatus = SpeakStatus.STOP;
	private SpeakForm mSpeakForm = SpeakForm.TIPS;
	
	private static final int[] mRoleCn = {
		3,	//晓燕
		4,	//晓峰
		15,	//晓美
		
		51,	//许久
		52,	//许多
		53,	//晓萍
		54,	//唐老鸭
		55,	//许小宝
		56,	//大龙
		
		7,	//楠楠
		9,	//嘉嘉
		11,	//小倩
		14,	//晓蓉
		22,	//晓琳
		24,	//小强
		25,	//小坤
	};	//中文发音人
	
	private static final int[] mRoleEn = {
		20,	//凯瑟琳
		
		3,	//晓燕
		4,	//晓峰
		15,	//晓美
		
		51,	//许久
		52,	//许多
		53,	//晓萍
		54,	//唐老鸭
		55,	//许小宝
		56,	//大龙
	};	//英文发音人
	
	private static final int[] mEffect = {
		0,	//原声	
		2,	//回声
		3,	//机器人
		7,	//阴阳怪气
	};	//音效
	
	public interface OnTTSListener 
	{
		public void onSpeakCompleted();		//朗读完成
		public void onSpeakError();			//朗读错误
	}
	
	public enum SpeakForm
	{
		TIPS,	//提示
		CONTENT,//内容
	}	//朗读形式
	
	public enum SpeakStatus
	{
		STOP, 	//停止
		PAUSE,	//暂停
		SPEAK,	//朗读
	}	//朗读状态
	
	//设置监听器
	public void OnTTSListener( OnTTSListener listener )
	{
		mOnTTSListener = listener;
	}
	
	//得到当前TTS状态
	public SpeakStatus getSpeakStatus()
	{
		return	mSpeakStatus;
	}
	
	public static TTSUtils getInstance()
	{
		if( null == instance )
		{
			instance = new TTSUtils();
		}
		
		return instance;
	}
	
	//得到TTS对象
	public SpeechServiceUtil getTextToSpeech()
	{
		return	mService;
	}
	
	//初始化
	public void init( Context context )
	{
		mContext = context.getApplicationContext();
		
		mSharedPreferences = mContext.getSharedPreferences(EbookConstants.TTS_SETTINGS, Activity.MODE_PRIVATE);
		//String resType = mSharedPreferences.getString("tts_resource", "0");
        // 合成对象初始化
        ttsParamsIntent = new Intent();
        Intent serviceIntent = new Intent();
        serviceIntent.putExtra(SpeechIntent.SERVICE_LOG_ENABLE, true);
        mService = new SpeechServiceUtil(mContext, mInitListener, serviceIntent);
	}
	
	//销毁
	public void destroy()
	{
		if(mService != null)
		{
			mService.destroy();
			mService = null;
		}
	}

	//是否初始化成功
	public boolean isSuccess()
	{
		return	isSuccess;
	}
{'fraction_non_alphanumeric': 0.11879916519505539, 'fraction_numerical': 0.016375020067426554, 'mean_word_length': 3.109498680738786, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2003831', 'n_tokens_mistral': 2800, 'n_tokens_neox': 2622, 'n_words': 530}