working on baidu tts

This commit is contained in:
wangmi 2017-02-16 23:22:14 +08:00
parent b21814ab03
commit b34df04cbe
8 changed files with 58 additions and 47 deletions

View File

@ -35,7 +35,7 @@ dependencies {
compile files('libs/SocialSDK_tencentWB_1.jar')
compile files('libs/SocialSDK_tencentWB_2.jar')
compile files('libs/SocialSDK_tencentWB_3.jar')
compile files('libs/SpeechApi.jar')
// compile files('libs/SpeechApi.jar')
compile files('libs/achartengine-1.1.0.jar')
compile files('libs/android-async-http-1.4.6.jar')
compile files('libs/conceal_android.jar')

View File

@ -77,7 +77,7 @@
<!--android:name="com.baidu.lbsapi.API_KEY"-->
<!--android:value="4lcFzBPFbukDG9DulM4qjjaI"-->
<!--/>-->
<!---->

View File

@ -2621,15 +2621,7 @@ public TypeStatistics getTracksStat(int trackType,long startDate,long endDate)
}
void stopMts(){
// mTts.stopSpeaking(mTtsListener);
//// // ?嚭鏃堕噴鏀捐繛鎺?
// mTts.destory();
mTts.stop();
}
/**创建HttpClient实例
* @return
*/
@ -2779,6 +2771,7 @@ public TypeStatistics getTracksStat(int trackType,long startDate,long endDate)
}
}
private void initialEnv() {
QLog.getLogger().d(dTAG,"begin to copy bdtts assets to sd ...");
if (mSampleDirPath == null) {
String sdcardPath = Environment.getExternalStorageDirectory().toString();
mSampleDirPath = sdcardPath + "/qiyou/" + SAMPLE_DIR_NAME;
@ -2794,6 +2787,8 @@ public TypeStatistics getTracksStat(int trackType,long startDate,long endDate)
// + ENGLISH_SPEECH_MALE_MODEL_NAME);
// copyFromAssetsToSdcard(false, "english/" + ENGLISH_TEXT_MODEL_NAME, mSampleDirPath + "/"
// + ENGLISH_TEXT_MODEL_NAME);
QLog.getLogger().d(dTAG," copy bdtts assets to sd ...done");
}
/**
@ -2841,6 +2836,7 @@ public TypeStatistics getTracksStat(int trackType,long startDate,long endDate)
}
private void initialSpeech(){
QLog.getLogger().d(dTAG,"begin to initial bd tts speach....");
initialEnv();
this.mTts = SpeechSynthesizer.getInstance();
this.mTts.setContext(this);
@ -2874,10 +2870,10 @@ public TypeStatistics getTracksStat(int trackType,long startDate,long endDate)
AuthInfo authInfo = this.mTts.auth(TtsMode.MIX);
if (authInfo.isSuccess()) {
QLog.getLogger().d(dTAG, "baidu tts auth success" );
// QLog.getLogger().d(dTAG, "baidu tts auth success" );
} else {
String errorMsg = authInfo.getTtsError().getDetailMessage();
QLog.getLogger().d(dTAG, "baidu tts auth fail" );
// QLog.getLogger().d(dTAG, "baidu tts auth fail" );
}
// 初始化tts
@ -2930,6 +2926,10 @@ public TypeStatistics getTracksStat(int trackType,long startDate,long endDate)
String spkS = s;
int progress = i;
bdSpeaking = lastSpeakWordLenght > i;
// QLog.getLogger().d(dTAG,"speaking: " + lastSpeakWord + ", length " + lastSpeakWordLenght +", progress is: " + i +",bdSpeaking: " +bdSpeaking);
}
@Override
@ -2948,6 +2948,8 @@ public TypeStatistics getTracksStat(int trackType,long startDate,long endDate)
private int speekingLevel=0;
int sumSleep = 0;
int lastSpeakWordLenght = 0;
String lastSpeakWord ="";
public void speech(final String text,final int level){
// if(!QiYouConstant.CAN_SPEAK)return;
@ -2957,22 +2959,28 @@ public TypeStatistics getTracksStat(int trackType,long startDate,long endDate)
@Override
public void run() {
while(bdSpeaking &&level <=speekingLevel && sumSleep > 5000){
while(bdSpeaking &&level <=speekingLevel && sumSleep < 5000 ){
try {
Thread.sleep(1000);
// QLog.getLogger().d(dTAG,"speaking: waiting..... " + sumSleep);
sumSleep +=1000;
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if (sumSleep > 0 || bdSpeaking &&level > speekingLevel){
mTts.stop();
}
sumSleep =0;
mTts.stop();
// bdSpeaking = false;
speekingLevel =level;
mTts.speak(text);
lastSpeakWord = text;
lastSpeakWordLenght = text.length();
}}.start();
}
@ -2998,6 +3006,16 @@ public TypeStatistics getTracksStat(int trackType,long startDate,long endDate)
}
void stopMts(){
// mTts.stopSpeaking(mTtsListener);
//// // ?嚭鏃堕噴鏀捐繛鎺?
// mTts.destory();
mTts.stop();
mTts.freeCustomResource();
mTts.release();
}
//xunfei is below....

View File

@ -257,7 +257,7 @@ public class TrackPlaybackService extends IntentService {
app.naviUI(loc, msg);
msg =QiYouConstant.PV_INT_NAVI_SPEAK_MODEL==0?msg:geo;
if (lastspdDist != lastDist){
if (lastspdDist != lastDist /* && !app.playbackPaused*/){
app.speech( msg,1);
}
@ -304,7 +304,7 @@ public class TrackPlaybackService extends IntentService {
//TODO: CHECK WHY STUCK HERE WHEN CHANGE CURRENT PLAY BACK TRACK.
int totalSleep =0;
while(i>1 && totalSleep<6000 &&(app.playbackPaused ||QiYouConstant.CAN_SPEAK && app.isSpeaking())){
while(i>1 /*&& totalSleep<6000 */ &&(app.playbackPaused ||QiYouConstant.CAN_SPEAK && app.isSpeaking())){
// QLog.getLogger().d(dTAG,String.format(" is speeaking ?%s, total sleep %s",QiYouConstant.CAN_SPEAK && app.isSpeaking(), totalSleep));

View File

@ -1,39 +1,30 @@
package com.qiyou.mb.android.ui;
import java.util.ArrayList;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.RemoteException;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.iflytek.speech.ErrorCode;
import com.iflytek.speech.ISpeechModule;
import com.iflytek.speech.InitListener;
import com.iflytek.speech.SpeechConstant;
import com.iflytek.speech.SpeechSynthesizer;
import com.iflytek.speech.SpeechUtility;
import com.iflytek.speech.SynthesizerListener;
import com.qiyou.mb.android.Activity_qiyouBase;
import com.qiyou.mb.android.QiYouApplication;
import com.qiyou.mb.android.QiYouConstant;
import com.qiyou.mb.android.R;
import com.qiyou.mb.android.beans.Track;
import com.qiyou.mb.android.ui.charts.AbstractChart;
import com.qiyou.mb.android.ui.charts.DistEleChartNoDown;
import com.qiyou.mb.android.ui.charts.DistKmSpeedChart;
import com.qiyou.mb.android.ui.charts.DistSpeedChart;
import com.qiyou.mb.android.upgrade.UpdateManager;
import com.qiyou.mb.android.utils.Utils;
import com.qiyou.mb.android.utils.log.QLog;
import java.util.ArrayList;
//import com.iflytek.speech.ErrorCode;
//import com.iflytek.speech.ISpeechModule;
//import com.iflytek.speech.InitListener;
//import com.iflytek.speech.SpeechConstant;
//import com.iflytek.speech.SpeechSynthesizer;
//import com.iflytek.speech.SpeechUtility;
//import com.iflytek.speech.SynthesizerListener;
public class ChartSpeedKm extends Activity_qiyouBase {
public static final String TAG ="com.qiyou.About";

View File

@ -19,13 +19,13 @@ import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import com.iflytek.speech.ErrorCode;
import com.iflytek.speech.ISpeechModule;
import com.iflytek.speech.InitListener;
import com.iflytek.speech.SpeechConstant;
import com.iflytek.speech.SpeechSynthesizer;
import com.iflytek.speech.SpeechUtility;
import com.iflytek.speech.SynthesizerListener;
//import com.iflytek.speech.ErrorCode;
//import com.iflytek.speech.ISpeechModule;
//import com.iflytek.speech.InitListener;
//import com.iflytek.speech.SpeechConstant;
//import com.iflytek.speech.SpeechSynthesizer;
//import com.iflytek.speech.SpeechUtility;
//import com.iflytek.speech.SynthesizerListener;
import com.qiyou.mb.android.Activity_qiyouBase;
import com.qiyou.mb.android.QiYouApplication;
import com.qiyou.mb.android.QiYouConstant;

View File

@ -12,7 +12,6 @@ import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;
import com.baidu.mapapi.map.Polyline;
import com.qiyou.mb.android.QiYouConstant;
import com.qiyou.mb.android.R;
import com.qiyou.mb.android.service.QNaviSvc;
@ -219,7 +218,10 @@ protected void startStopPlay(){
}
QiYouConstant.CAN_SPEAK = !isPlayPause ;
mSpeedText.setText(isPlayPause?"回放暂停":"回放继续") ;
String pre = activity.app.isNaving ? "模拟" :"回放";
String words = pre + ( isPlayPause?"暂停":"继续" );
mSpeedText.setText(words) ;
activity.app.speech(words,10);
}

View File

@ -720,7 +720,7 @@ public class Route_fragment extends TrackTabs_fragment implements IlocationFra
wb.setRoadBook(lastRoadbook);
// wb.setComment(content);
QLog.getLogger().d(dTAG, String.format(" roadbook is %s , turnflag is %s ", lastRoadbook,wb.getTurnFlag().toCHString() ));
// QLog.getLogger().d(dTAG, String.format(" roadbook is %s , turnflag is %s ", lastRoadbook,wb.getTurnFlag().toCHString() ));
// wb.setTurnFlag(wpFlag.CUST);
roadWbs.add(wb);
// starttime+=timestep;
@ -773,7 +773,7 @@ public class Route_fragment extends TrackTabs_fragment implements IlocationFra
cleanRoadInfo();
wb.setBearing(step.getDirection()*directionRate);
QLog.getLogger().d(dTAG, String.format(" instructions %s \n existinstruction %s | entranceInstruction %s", instructions,exitInstruction,entranceInstruction));
// QLog.getLogger().d(dTAG, String.format(" instructions %s \n existinstruction %s | entranceInstruction %s", instructions,exitInstruction,entranceInstruction));
flag= exitInstruction.startsWith(wpFlag.TURNLEFT.toCHString())?wpFlag.TURNLEFT