opt
This commit is contained in:
@@ -6,6 +6,7 @@ import android.content.Intent;
|
|||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import com.mogo.commons.AbsMogoApplication;
|
||||||
import com.mogo.utils.logger.Logger;
|
import com.mogo.utils.logger.Logger;
|
||||||
import com.zhidao.auto.platform.voice.VoiceClient;
|
import com.zhidao.auto.platform.voice.VoiceClient;
|
||||||
import com.zhidao.voicesdk.MogoVoiceManager;
|
import com.zhidao.voicesdk.MogoVoiceManager;
|
||||||
@@ -81,7 +82,9 @@ public class AIAssist implements VoiceClient.VoiceCmdCallBack, OnTtsListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initFlushStatus( Context context ) {
|
private void initFlushStatus( Context context ) {
|
||||||
mHasFlush = isVoiceServiceReady( context );
|
if ( !mHasFlush ) {
|
||||||
|
mHasFlush = isVoiceServiceReady( context );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -194,6 +197,7 @@ public class AIAssist implements VoiceClient.VoiceCmdCallBack, OnTtsListener {
|
|||||||
*/
|
*/
|
||||||
public void speakTTSVoice( String text, IMogoVoiceCmdCallBack callBack ) {
|
public void speakTTSVoice( String text, IMogoVoiceCmdCallBack callBack ) {
|
||||||
try {
|
try {
|
||||||
|
initFlushStatus( AbsMogoApplication.getApp() );
|
||||||
if ( mHasFlush ) {
|
if ( mHasFlush ) {
|
||||||
mSpeakVoiceMap.put( text, callBack );
|
mSpeakVoiceMap.put( text, callBack );
|
||||||
mVoiceClient.speakDefault( text );
|
mVoiceClient.speakDefault( text );
|
||||||
@@ -209,6 +213,7 @@ public class AIAssist implements VoiceClient.VoiceCmdCallBack, OnTtsListener {
|
|||||||
*/
|
*/
|
||||||
public void speakTTSVoice( String text ) {
|
public void speakTTSVoice( String text ) {
|
||||||
try {
|
try {
|
||||||
|
initFlushStatus( AbsMogoApplication.getApp() );
|
||||||
if ( mHasFlush ) {
|
if ( mHasFlush ) {
|
||||||
mVoiceClient.speakDefault( text );
|
mVoiceClient.speakDefault( text );
|
||||||
}
|
}
|
||||||
@@ -224,6 +229,7 @@ public class AIAssist implements VoiceClient.VoiceCmdCallBack, OnTtsListener {
|
|||||||
*/
|
*/
|
||||||
public void speakTTSVoice( String text, VoicePreemptType type, IMogoVoiceCmdCallBack callBack ) {
|
public void speakTTSVoice( String text, VoicePreemptType type, IMogoVoiceCmdCallBack callBack ) {
|
||||||
try {
|
try {
|
||||||
|
initFlushStatus( AbsMogoApplication.getApp() );
|
||||||
if ( mHasFlush ) {
|
if ( mHasFlush ) {
|
||||||
mSpeakVoiceMap.put( text, callBack );
|
mSpeakVoiceMap.put( text, callBack );
|
||||||
mVoiceClient.speakTypeText( text, type.getPreemptType() );
|
mVoiceClient.speakTypeText( text, type.getPreemptType() );
|
||||||
@@ -238,6 +244,7 @@ public class AIAssist implements VoiceClient.VoiceCmdCallBack, OnTtsListener {
|
|||||||
* @param tts 播报内容
|
* @param tts 播报内容
|
||||||
*/
|
*/
|
||||||
public void speakQAndACmd( String tts, IMogoVoiceCmdCallBack callBack ) {
|
public void speakQAndACmd( String tts, IMogoVoiceCmdCallBack callBack ) {
|
||||||
|
initFlushStatus( AbsMogoApplication.getApp() );
|
||||||
if ( mHasFlush ) {
|
if ( mHasFlush ) {
|
||||||
mQAndAMap.put( tts, callBack );
|
mQAndAMap.put( tts, callBack );
|
||||||
mVoiceClient.speakTtsAndRegistCmd( tts );
|
mVoiceClient.speakTtsAndRegistCmd( tts );
|
||||||
@@ -252,6 +259,7 @@ public class AIAssist implements VoiceClient.VoiceCmdCallBack, OnTtsListener {
|
|||||||
* @param cancelCmds 取消命令唤醒词
|
* @param cancelCmds 取消命令唤醒词
|
||||||
*/
|
*/
|
||||||
public void speakQAndACmd( String tts, String[] okCmds, String[] cancelCmds, IMogoVoiceCmdCallBack callBack ) {
|
public void speakQAndACmd( String tts, String[] okCmds, String[] cancelCmds, IMogoVoiceCmdCallBack callBack ) {
|
||||||
|
initFlushStatus( AbsMogoApplication.getApp() );
|
||||||
if ( mHasFlush ) {
|
if ( mHasFlush ) {
|
||||||
mQAndAMap.put( tts, callBack );
|
mQAndAMap.put( tts, callBack );
|
||||||
mVoiceClient.speakTtsAndRegistCmd( tts, okCmds, cancelCmds );
|
mVoiceClient.speakTtsAndRegistCmd( tts, okCmds, cancelCmds );
|
||||||
@@ -271,6 +279,7 @@ public class AIAssist implements VoiceClient.VoiceCmdCallBack, OnTtsListener {
|
|||||||
}
|
}
|
||||||
mCmdMap.get( cmd ).add( callBack );
|
mCmdMap.get( cmd ).add( callBack );
|
||||||
|
|
||||||
|
initFlushStatus( AbsMogoApplication.getApp() );
|
||||||
if ( mHasFlush ) {
|
if ( mHasFlush ) {
|
||||||
mVoiceClient.registerCustomWakeupCmd( cmd, cmdWords );
|
mVoiceClient.registerCustomWakeupCmd( cmd, cmdWords );
|
||||||
mCacheUnWakeupCommands.remove( cmd );
|
mCacheUnWakeupCommands.remove( cmd );
|
||||||
@@ -286,6 +295,7 @@ public class AIAssist implements VoiceClient.VoiceCmdCallBack, OnTtsListener {
|
|||||||
* @param cmdWords
|
* @param cmdWords
|
||||||
*/
|
*/
|
||||||
public void registerUnWakeupCommand( String cmd, String[] cmdWords ) {
|
public void registerUnWakeupCommand( String cmd, String[] cmdWords ) {
|
||||||
|
initFlushStatus( AbsMogoApplication.getApp() );
|
||||||
if ( mHasFlush ) {
|
if ( mHasFlush ) {
|
||||||
mVoiceClient.registerCustomWakeupCmd( cmd, cmdWords );
|
mVoiceClient.registerCustomWakeupCmd( cmd, cmdWords );
|
||||||
mCacheUnWakeupCommands.remove( cmd );
|
mCacheUnWakeupCommands.remove( cmd );
|
||||||
|
|||||||
Reference in New Issue
Block a user