/** * 播报短信内容 * * @param content */ protected void broadcastContent(String content) { SpeechSynthesizer tts = SpeachHelper.getInstance(mContext).getSpeechSynthesizer(); if (null != tts) { if (tts.isSpeaking()) { tts.stopSpeaking(); } else { tts.startSpeaking(content, mSynListener); } } }
/** * 使用SpeechSynthesizer合成语音,不弹出合成Dialog. * * @param */ public void playText(String playText) { if (!isfinish) { return; } if (null == mSpeechSynthesizer) { // 创建合成对象. mSpeechSynthesizer = SpeechSynthesizer.createSynthesizer(mContext, minitListener); initSpeechSynthesizer(); } mSpeechSynthesizer.startSpeaking(playText, this); }
/** 启动语音播放 */ public void playSpeech(String text) { // 设置参数 setParam2(); // 朗读 int code = mTts.startSpeaking(text, mTtsListener); if (code != ErrorCode.SUCCESS) { if (code == ErrorCode.ERROR_COMPONENT_NOT_INSTALLED) { // 未安装则跳转到提示安装页面 } else { Toast.makeText(RecodeActivity.this, "语音合成失败,错误码: " + code, Toast.LENGTH_SHORT).show(); } } }
private void startTts(String text) { int code = mTts.startSpeaking(text, (com.iflytek.cloud.SynthesizerListener) mTtsListener); if (code != ErrorCode.SUCCESS) { System.out.println(code); } }