working on baidu tts
This commit is contained in:
		
							parent
							
								
									b21814ab03
								
							
						
					
					
						commit
						b34df04cbe
					
				|  | @ -35,7 +35,7 @@ dependencies { | ||||||
|     compile files('libs/SocialSDK_tencentWB_1.jar') |     compile files('libs/SocialSDK_tencentWB_1.jar') | ||||||
|     compile files('libs/SocialSDK_tencentWB_2.jar') |     compile files('libs/SocialSDK_tencentWB_2.jar') | ||||||
|     compile files('libs/SocialSDK_tencentWB_3.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/achartengine-1.1.0.jar') | ||||||
|     compile files('libs/android-async-http-1.4.6.jar') |     compile files('libs/android-async-http-1.4.6.jar') | ||||||
|     compile files('libs/conceal_android.jar') |     compile files('libs/conceal_android.jar') | ||||||
|  |  | ||||||
|  | @ -77,7 +77,7 @@ | ||||||
| 	            <!--android:name="com.baidu.lbsapi.API_KEY"--> | 	            <!--android:name="com.baidu.lbsapi.API_KEY"--> | ||||||
| 	             <!--android:value="4lcFzBPFbukDG9DulM4qjjaI"--> | 	             <!--android:value="4lcFzBPFbukDG9DulM4qjjaI"--> | ||||||
| 	             <!--/>--> | 	             <!--/>--> | ||||||
|            <!----> | 
 | ||||||
| 
 | 
 | ||||||
|             |             | ||||||
|           |           | ||||||
|  |  | ||||||
|  | @ -2621,15 +2621,7 @@ public   TypeStatistics getTracksStat(int trackType,long startDate,long endDate) | ||||||
| 		 | 		 | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	 void stopMts(){ |  | ||||||
| //		 mTts.stopSpeaking(mTtsListener); |  | ||||||
| ////        // 閫?嚭鏃堕噴鏀捐繛鎺? |  | ||||||
| //		mTts.destory(); |  | ||||||
| 
 | 
 | ||||||
| 		 mTts.stop(); |  | ||||||
| 
 |  | ||||||
| 	 } |  | ||||||
|   |  | ||||||
| 	/**创建HttpClient实例 | 	/**创建HttpClient实例 | ||||||
| 	 * @return | 	 * @return | ||||||
| 	 */ | 	 */ | ||||||
|  | @ -2779,6 +2771,7 @@ public   TypeStatistics getTracksStat(int trackType,long startDate,long endDate) | ||||||
| 		 } | 		 } | ||||||
| 	 } | 	 } | ||||||
| 	 private void initialEnv() { | 	 private void initialEnv() { | ||||||
|  | 		 QLog.getLogger().d(dTAG,"begin to copy bdtts assets to sd ..."); | ||||||
| 		 if (mSampleDirPath == null) { | 		 if (mSampleDirPath == null) { | ||||||
| 			 String sdcardPath = Environment.getExternalStorageDirectory().toString(); | 			 String sdcardPath = Environment.getExternalStorageDirectory().toString(); | ||||||
| 			 mSampleDirPath = sdcardPath + "/qiyou/" + SAMPLE_DIR_NAME; | 			 mSampleDirPath = sdcardPath + "/qiyou/" + SAMPLE_DIR_NAME; | ||||||
|  | @ -2794,6 +2787,8 @@ public   TypeStatistics getTracksStat(int trackType,long startDate,long endDate) | ||||||
| //				 + ENGLISH_SPEECH_MALE_MODEL_NAME); | //				 + ENGLISH_SPEECH_MALE_MODEL_NAME); | ||||||
| //		 copyFromAssetsToSdcard(false, "english/" + ENGLISH_TEXT_MODEL_NAME, mSampleDirPath + "/" | //		 copyFromAssetsToSdcard(false, "english/" + ENGLISH_TEXT_MODEL_NAME, mSampleDirPath + "/" | ||||||
| //				 + ENGLISH_TEXT_MODEL_NAME); | //				 + 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(){ | 	 private void initialSpeech(){ | ||||||
|  | 		 QLog.getLogger().d(dTAG,"begin to initial bd tts speach...."); | ||||||
| 		 initialEnv(); | 		 initialEnv(); | ||||||
| 		 this.mTts = SpeechSynthesizer.getInstance(); | 		 this.mTts = SpeechSynthesizer.getInstance(); | ||||||
| 		 this.mTts.setContext(this); | 		 this.mTts.setContext(this); | ||||||
|  | @ -2874,10 +2870,10 @@ public   TypeStatistics getTracksStat(int trackType,long startDate,long endDate) | ||||||
| 		 AuthInfo authInfo = this.mTts.auth(TtsMode.MIX); | 		 AuthInfo authInfo = this.mTts.auth(TtsMode.MIX); | ||||||
| 
 | 
 | ||||||
| 		 if (authInfo.isSuccess()) { | 		 if (authInfo.isSuccess()) { | ||||||
| 			 QLog.getLogger().d(dTAG, "baidu tts auth success"  ); | //			 QLog.getLogger().d(dTAG, "baidu tts auth success"  ); | ||||||
| 		 } else { | 		 } else { | ||||||
| 			 String errorMsg = authInfo.getTtsError().getDetailMessage(); | 			 String errorMsg = authInfo.getTtsError().getDetailMessage(); | ||||||
| 			 QLog.getLogger().d(dTAG, "baidu tts auth fail"  ); | //			 QLog.getLogger().d(dTAG, "baidu tts auth fail"  ); | ||||||
| 		 } | 		 } | ||||||
| 
 | 
 | ||||||
| 		 // 初始化tts | 		 // 初始化tts | ||||||
|  | @ -2930,6 +2926,10 @@ public   TypeStatistics getTracksStat(int trackType,long startDate,long endDate) | ||||||
| 
 | 
 | ||||||
| 			String spkS = s; | 			String spkS = s; | ||||||
| 			int progress = i; | 			int progress = i; | ||||||
|  | 			bdSpeaking = lastSpeakWordLenght > i; | ||||||
|  | //			QLog.getLogger().d(dTAG,"speaking: " + lastSpeakWord + ", length " + lastSpeakWordLenght +", progress is: " + i +",bdSpeaking: " +bdSpeaking); | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		@Override | 		@Override | ||||||
|  | @ -2948,6 +2948,8 @@ public   TypeStatistics getTracksStat(int trackType,long startDate,long endDate) | ||||||
| 
 | 
 | ||||||
| 	 private int speekingLevel=0; | 	 private int speekingLevel=0; | ||||||
| 	 int sumSleep = 0; | 	 int sumSleep = 0; | ||||||
|  | 	 int lastSpeakWordLenght = 0; | ||||||
|  | 	 String lastSpeakWord =""; | ||||||
| 	 public void speech(final String text,final int level){ | 	 public void speech(final String text,final int level){ | ||||||
| // 		 if(!QiYouConstant.CAN_SPEAK)return; | // 		 if(!QiYouConstant.CAN_SPEAK)return; | ||||||
| 
 | 
 | ||||||
|  | @ -2957,22 +2959,28 @@ public   TypeStatistics getTracksStat(int trackType,long startDate,long endDate) | ||||||
| 
 | 
 | ||||||
| 			 @Override | 			 @Override | ||||||
| 			 public void run() { | 			 public void run() { | ||||||
| 				 while(bdSpeaking &&level <=speekingLevel && sumSleep > 5000){ | 				 while(bdSpeaking &&level <=speekingLevel  && sumSleep < 5000 ){ | ||||||
| 					 try { | 					 try { | ||||||
| 						 Thread.sleep(1000); | 						 Thread.sleep(1000); | ||||||
|  | //						 QLog.getLogger().d(dTAG,"speaking: waiting..... " + sumSleep); | ||||||
| 						 sumSleep +=1000; | 						 sumSleep +=1000; | ||||||
| 					 } catch (InterruptedException e) { | 					 } catch (InterruptedException e) { | ||||||
| 						 // TODO Auto-generated catch block | 						 // TODO Auto-generated catch block | ||||||
| 						 e.printStackTrace(); | 						 e.printStackTrace(); | ||||||
| 					 } | 					 } | ||||||
| 				 } | 				 } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 				 if (sumSleep > 0 || bdSpeaking &&level > speekingLevel){ | ||||||
|  | 					 mTts.stop(); | ||||||
|  | 				 } | ||||||
| 				 sumSleep =0; | 				 sumSleep =0; | ||||||
| 				 mTts.stop(); |  | ||||||
| //				 bdSpeaking = false; | //				 bdSpeaking = false; | ||||||
| 				 speekingLevel =level; | 				 speekingLevel =level; | ||||||
| 
 | 
 | ||||||
| 				 mTts.speak(text); | 				 mTts.speak(text); | ||||||
| 
 | 				 lastSpeakWord = text; | ||||||
|  | 				 lastSpeakWordLenght = text.length(); | ||||||
| 			 }}.start(); | 			 }}.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.... | //xunfei is below.... | ||||||
|  |  | ||||||
|  | @ -257,7 +257,7 @@ public class TrackPlaybackService extends IntentService { | ||||||
| 								 app.naviUI(loc, msg); | 								 app.naviUI(loc, msg); | ||||||
| 								 msg =QiYouConstant.PV_INT_NAVI_SPEAK_MODEL==0?msg:geo; | 								 msg =QiYouConstant.PV_INT_NAVI_SPEAK_MODEL==0?msg:geo; | ||||||
| 								  | 								  | ||||||
| 								 if (lastspdDist != lastDist){ | 								 if (lastspdDist != lastDist /* && !app.playbackPaused*/){ | ||||||
| 									 app.speech( msg,1); | 									 app.speech( msg,1); | ||||||
| 								 } | 								 } | ||||||
| 								 | 								 | ||||||
|  | @ -304,7 +304,7 @@ public class TrackPlaybackService extends IntentService { | ||||||
| 						 | 						 | ||||||
| 						 //TODO: CHECK WHY STUCK HERE WHEN CHANGE CURRENT PLAY BACK TRACK. | 						 //TODO: CHECK WHY STUCK HERE WHEN CHANGE CURRENT PLAY BACK TRACK. | ||||||
| 						   int totalSleep =0; | 						   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)); | //			 					 QLog.getLogger().d(dTAG,String.format(" is speeaking ?%s, total sleep  %s",QiYouConstant.CAN_SPEAK && app.isSpeaking(), totalSleep)); | ||||||
| 			 				  | 			 				  | ||||||
|  |  | ||||||
|  | @ -1,39 +1,30 @@ | ||||||
| package com.qiyou.mb.android.ui; | package com.qiyou.mb.android.ui; | ||||||
| 
 | 
 | ||||||
| import java.util.ArrayList; |  | ||||||
| 
 |  | ||||||
| import android.os.Bundle; | 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; | ||||||
| import android.view.View.OnClickListener; |  | ||||||
| import android.view.ViewGroup.LayoutParams; | import android.view.ViewGroup.LayoutParams; | ||||||
| import android.widget.Button; |  | ||||||
| import android.widget.LinearLayout; | import android.widget.LinearLayout; | ||||||
| import android.widget.TextView; | 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.Activity_qiyouBase; | ||||||
| import com.qiyou.mb.android.QiYouApplication; | import com.qiyou.mb.android.QiYouApplication; | ||||||
| import com.qiyou.mb.android.QiYouConstant; |  | ||||||
| import com.qiyou.mb.android.R; | import com.qiyou.mb.android.R; | ||||||
| import com.qiyou.mb.android.beans.Track; | import com.qiyou.mb.android.beans.Track; | ||||||
| import com.qiyou.mb.android.ui.charts.AbstractChart; | import com.qiyou.mb.android.ui.charts.AbstractChart; | ||||||
| import com.qiyou.mb.android.ui.charts.DistEleChartNoDown; | import com.qiyou.mb.android.ui.charts.DistEleChartNoDown; | ||||||
| import com.qiyou.mb.android.ui.charts.DistKmSpeedChart; | import com.qiyou.mb.android.ui.charts.DistKmSpeedChart; | ||||||
| import com.qiyou.mb.android.ui.charts.DistSpeedChart; | 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.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 class ChartSpeedKm extends Activity_qiyouBase { | ||||||
| 	public static final String TAG ="com.qiyou.About"; | 	public static final String TAG ="com.qiyou.About"; | ||||||
|  |  | ||||||
|  | @ -19,13 +19,13 @@ import android.widget.ProgressBar; | ||||||
| import android.widget.TextView; | import android.widget.TextView; | ||||||
| import android.widget.Toast; | import android.widget.Toast; | ||||||
| 
 | 
 | ||||||
| import com.iflytek.speech.ErrorCode; | //import com.iflytek.speech.ErrorCode; | ||||||
| import com.iflytek.speech.ISpeechModule; | //import com.iflytek.speech.ISpeechModule; | ||||||
| import com.iflytek.speech.InitListener; | //import com.iflytek.speech.InitListener; | ||||||
| import com.iflytek.speech.SpeechConstant; | //import com.iflytek.speech.SpeechConstant; | ||||||
| import com.iflytek.speech.SpeechSynthesizer; | //import com.iflytek.speech.SpeechSynthesizer; | ||||||
| import com.iflytek.speech.SpeechUtility; | //import com.iflytek.speech.SpeechUtility; | ||||||
| import com.iflytek.speech.SynthesizerListener; | //import com.iflytek.speech.SynthesizerListener; | ||||||
| import com.qiyou.mb.android.Activity_qiyouBase; | import com.qiyou.mb.android.Activity_qiyouBase; | ||||||
| import com.qiyou.mb.android.QiYouApplication; | import com.qiyou.mb.android.QiYouApplication; | ||||||
| import com.qiyou.mb.android.QiYouConstant; | import com.qiyou.mb.android.QiYouConstant; | ||||||
|  |  | ||||||
|  | @ -12,7 +12,6 @@ import android.widget.SeekBar; | ||||||
| import android.widget.SeekBar.OnSeekBarChangeListener; | import android.widget.SeekBar.OnSeekBarChangeListener; | ||||||
| import android.widget.TextView; | import android.widget.TextView; | ||||||
| 
 | 
 | ||||||
| import com.baidu.mapapi.map.Polyline; |  | ||||||
| import com.qiyou.mb.android.QiYouConstant; | import com.qiyou.mb.android.QiYouConstant; | ||||||
| import com.qiyou.mb.android.R; | import com.qiyou.mb.android.R; | ||||||
| import com.qiyou.mb.android.service.QNaviSvc; | import com.qiyou.mb.android.service.QNaviSvc; | ||||||
|  | @ -219,7 +218,10 @@ protected  void startStopPlay(){ | ||||||
| 				  | 				  | ||||||
| 			}   | 			}   | ||||||
| 	    	 QiYouConstant.CAN_SPEAK  = !isPlayPause ; | 	    	 QiYouConstant.CAN_SPEAK  = !isPlayPause ; | ||||||
| 	    	mSpeedText.setText(isPlayPause?"回放暂停":"回放继续") ; | 		    String pre = activity.app.isNaving ? "模拟" :"回放"; | ||||||
|  | 			String words = pre + ( isPlayPause?"暂停":"继续" ); | ||||||
|  | 	    	mSpeedText.setText(words) ; | ||||||
|  | 			activity.app.speech(words,10); | ||||||
| 	    }  | 	    }  | ||||||
| 	  | 	  | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -720,7 +720,7 @@ public class Route_fragment extends  TrackTabs_fragment  implements IlocationFra | ||||||
| 		 					 | 		 					 | ||||||
| 		 					wb.setRoadBook(lastRoadbook);	 | 		 					wb.setRoadBook(lastRoadbook);	 | ||||||
| //		 					wb.setComment(content); | //		 					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); | //		 					wb.setTurnFlag(wpFlag.CUST); | ||||||
| 		 					roadWbs.add(wb); | 		 					roadWbs.add(wb); | ||||||
| //		 					starttime+=timestep; | //		 					starttime+=timestep; | ||||||
|  | @ -773,7 +773,7 @@ public class Route_fragment extends  TrackTabs_fragment  implements IlocationFra | ||||||
| 							cleanRoadInfo(); | 							cleanRoadInfo(); | ||||||
| 		 					wb.setBearing(step.getDirection()*directionRate); | 		 					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 | 		 					flag= exitInstruction.startsWith(wpFlag.TURNLEFT.toCHString())?wpFlag.TURNLEFT | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue