|
|
|
|
@@ -3,13 +3,14 @@ package com.mogo.eagle.core.function.chat.facade.voice
|
|
|
|
|
import android.content.Context
|
|
|
|
|
import android.content.Intent
|
|
|
|
|
import com.mogo.commons.AbsMogoApplication
|
|
|
|
|
import com.mogo.commons.module.intent.IMogoIntentListener
|
|
|
|
|
import com.mogo.commons.module.intent.IntentManager
|
|
|
|
|
import com.mogo.commons.voice.AIAssist
|
|
|
|
|
import com.mogo.commons.voice.IMogoVoiceCmdCallBack
|
|
|
|
|
import com.mogo.eagle.core.function.api.chat.biz.IMoGoVoiceControlFacade
|
|
|
|
|
import com.mogo.eagle.core.function.api.chat.biz.IMoGoVoiceControlFacade.IMoGoVoiceCallback
|
|
|
|
|
import com.mogo.eagle.core.function.chat.facade.bridge.BridgeApi
|
|
|
|
|
import com.mogo.eagle.core.function.chat.facade.utils.log
|
|
|
|
|
import com.mogo.service.intent.IMogoIntentListener
|
|
|
|
|
import java.lang.ref.WeakReference
|
|
|
|
|
import java.util.concurrent.CopyOnWriteArrayList
|
|
|
|
|
import java.util.concurrent.atomic.AtomicBoolean
|
|
|
|
|
@@ -48,10 +49,6 @@ object VoiceControlFacade: IMoGoVoiceControlFacade, IMogoVoiceCmdCallBack, IMogo
|
|
|
|
|
|
|
|
|
|
private var onSpeechFinish: WeakReference<onSpeedFinish>? = null
|
|
|
|
|
|
|
|
|
|
private val intentManager by lazy {
|
|
|
|
|
BridgeApi.intentManager()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun speak(context: Context, content: String, listener: IMoGoVoiceCallback) {
|
|
|
|
|
listeners += WeakReference(listener)
|
|
|
|
|
AIAssist.getInstance(context).speakTTSVoiceWithLevel(content,AIAssist.LEVEL3 ,this)
|
|
|
|
|
@@ -123,10 +120,8 @@ object VoiceControlFacade: IMoGoVoiceControlFacade, IMogoVoiceCmdCallBack, IMogo
|
|
|
|
|
}
|
|
|
|
|
hasRegister.set(true)
|
|
|
|
|
AIAssist.getInstance(BridgeApi.context()).registerUnWakeupCommand(VOICE_REGISTER_CANCEL_CALL, customCancelCallArray, this)
|
|
|
|
|
intentManager?.also {
|
|
|
|
|
it.registerIntentListener(VOICE_INTENT_CANCEL_CALL_COMMAND, this)
|
|
|
|
|
it.registerIntentListener(VOICE_INTENT_REFUSE_CALL, this)
|
|
|
|
|
}
|
|
|
|
|
IntentManager.getInstance().registerIntentListener(VOICE_INTENT_CANCEL_CALL_COMMAND, this)
|
|
|
|
|
IntentManager.getInstance().registerIntentListener(VOICE_INTENT_REFUSE_CALL, this)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun registerInviteJoinTeam(context: Context, listener: IMoGoVoiceCallback) {
|
|
|
|
|
@@ -156,13 +151,13 @@ object VoiceControlFacade: IMoGoVoiceControlFacade, IMogoVoiceCmdCallBack, IMogo
|
|
|
|
|
|
|
|
|
|
override fun registerIntentInComingCall(listener: IMoGoVoiceCallback) {
|
|
|
|
|
listeners += WeakReference(listener)
|
|
|
|
|
intentManager?.registerIntentListener(VOICE_INTENT_ANSWER_CALL, this)
|
|
|
|
|
intentManager?.registerIntentListener(VOICE_INTENT_REFUSE_CALL, this)
|
|
|
|
|
IntentManager.getInstance().registerIntentListener(VOICE_INTENT_ANSWER_CALL, this)
|
|
|
|
|
IntentManager.getInstance().registerIntentListener(VOICE_INTENT_REFUSE_CALL, this)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun unRegisterIntentInComingCall(context: Context) {
|
|
|
|
|
intentManager?.unregisterIntentListener(VOICE_INTENT_ANSWER_CALL, this)
|
|
|
|
|
intentManager?.unregisterIntentListener(VOICE_INTENT_REFUSE_CALL, this)
|
|
|
|
|
IntentManager.getInstance().unregisterIntentListener(VOICE_INTENT_ANSWER_CALL, this)
|
|
|
|
|
IntentManager.getInstance().unregisterIntentListener(VOICE_INTENT_REFUSE_CALL, this)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun speakAndRegisterCall(onCmdAgree: (Boolean) -> Unit, onSpeakFinish: () -> Unit, listener: IMoGoVoiceCallback) {
|
|
|
|
|
@@ -204,10 +199,8 @@ object VoiceControlFacade: IMoGoVoiceControlFacade, IMogoVoiceCmdCallBack, IMogo
|
|
|
|
|
hasRegister.set(false)
|
|
|
|
|
listeners.clear()
|
|
|
|
|
AIAssist.getInstance(BridgeApi.context()).unregisterUnWakeupCommand(VOICE_REGISTER_CANCEL_CALL, this)
|
|
|
|
|
intentManager?.also {
|
|
|
|
|
it.unregisterIntentListener(VOICE_INTENT_CANCEL_CALL_COMMAND, this)
|
|
|
|
|
it.unregisterIntentListener(VOICE_INTENT_REFUSE_CALL, this)
|
|
|
|
|
}
|
|
|
|
|
IntentManager.getInstance().unregisterIntentListener(VOICE_INTENT_CANCEL_CALL_COMMAND, this)
|
|
|
|
|
IntentManager.getInstance().unregisterIntentListener(VOICE_INTENT_REFUSE_CALL, this)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun onIntentReceived(cmd: String?, intent: Intent?) {
|
|
|
|
|
|