diff --git a/OCH/mogo-och-common-module/src/debug/java/com/mogo/och/common/module/debug/DebugDataDispatch.kt b/OCH/mogo-och-common-module/src/debug/java/com/mogo/och/common/module/debug/DebugDataDispatch.kt index 3b4fd0068a..06b0a3311b 100644 --- a/OCH/mogo-och-common-module/src/debug/java/com/mogo/och/common/module/debug/DebugDataDispatch.kt +++ b/OCH/mogo-och-common-module/src/debug/java/com/mogo/och/common/module/debug/DebugDataDispatch.kt @@ -44,7 +44,7 @@ object DebugDataDispatch { const val trajectoryStation = "trajectoryStation" const val showDebugView = "showDebugView" -// aadb shell am broadcast -a com.mogo.launcher.debug -f 0x011000000 --es type "location" --es path "1111/11111" +// adb shell am broadcast -a com.mogo.launcher.debug -f 0x011000000 --es type "location" --es path "1111/11111" // adb shell am broadcast -a com.mogo.launcher.debug -f 0x011000000 --es type "globalPath" --es path "sy73.json" // adb shell am broadcast -a com.mogo.launcher.debug -f 0x011000000 --es type "carDoor" --ei doorPostion 1 --ei doorStatus 1 // adb shell am broadcast -a com.mogo.launcher.debug -f 0x011000000 --es type "trunAroud" --es code "IMAP_TRA_LOADED" @@ -53,10 +53,14 @@ object DebugDataDispatch { val ROOT_PATH = - Environment.getExternalStorageDirectory().absolutePath + File.separator + "MLog" + File.separator + "APPLog" + File.separator //程序外部存储跟目录 + Environment.getExternalStorageDirectory().absolutePath + File.separator + "MLog" + File.separator + "APP_mock" + File.separator //程序外部存储跟目录 fun disPathc(type: String?, frequency: Int, sourceFilePath: String?, intent: Intent) { + val file = File(ROOT_PATH); + if(file.exists()){ + + } when (type) { globalPathMock -> { sourceFilePath?.let { diff --git a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/ZhiView.kt b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/ZhiView.kt new file mode 100644 index 0000000000..177a36e5b8 --- /dev/null +++ b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/wigets/ZhiView.kt @@ -0,0 +1,77 @@ +package com.mogo.och.common.module.wigets + +import android.content.Context +import android.util.AttributeSet +import androidx.appcompat.widget.AppCompatImageView +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant +import com.mogo.och.common.module.R +import com.mogo.och.common.module.utils.FrameAnimatorContainer +import com.mogo.tts.base.zhi.AsrTextBean +import com.mogo.tts.base.zhi.CallbackWidget +import com.mogo.tts.base.zhi.AvatarManager +import com.mogo.tts.base.zhi.ZhiRecordWinUi + +class ZhiView @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +) : AppCompatImageView(context, attrs, defStyleAttr), + ZhiRecordWinUi { + companion object { + const val TAG = "ZhiView" + } + + private var createProgressDialogAnim: FrameAnimatorContainer?=null + + init { + createProgressDialogAnim = FrameAnimatorContainer(R.array.xiaozhi_normal, 20,this) + createProgressDialogAnim?.setOnAnimStopListener(object : FrameAnimatorContainer.OnAnimationStoppedListener{ + override fun AnimationStopped() { + CallerLogger.d(SceneConstant.M_TAXI_P + TAG, "动画暂停") + } + }) + } + + override fun onAttachedToWindow() { + super.onAttachedToWindow() + AvatarManager.addDistanceListener(TAG,this) + createProgressDialogAnim?.start() + } + + override fun onDetachedFromWindow() { + super.onDetachedFromWindow() + AvatarManager.removeListener(TAG) + } + + override fun start(reason: String?) { + CallerLogger.d(TAG,"-----start $reason") + } + + override fun onStatusChange(status: ZhiRecordWinUi.RecordStatus?) { + CallerLogger.d(TAG,"-----onStatusChange $status") + } + + override fun close(trigger: Boolean) { + CallerLogger.d(TAG,"-----close $trigger") + } + + override fun onVolumeChange(volume: Int) { + CallerLogger.d(TAG,"-----onVolumeChange $volume") + } + + override fun showInputText(asrTextBean: AsrTextBean?) { + CallerLogger.d(TAG,"-----showInputText $asrTextBean") + } + + override fun showOutPutWidget(callbackWidget: CallbackWidget?) { + // todo 咱不支持定制显示 包括天气 + CallerLogger.d(TAG,"-----showOutPutWidget $callbackWidget") + } + + override fun showOutputText(outPutText: String?) { + CallerLogger.d(TAG,"-----showOutputText $outPutText") + } + + +} diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal002.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal002.webp new file mode 100644 index 0000000000..f884ab93d7 Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal002.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal004.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal004.webp new file mode 100644 index 0000000000..df14aa223b Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal004.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal006.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal006.webp new file mode 100644 index 0000000000..77274eaa4d Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal006.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal008.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal008.webp new file mode 100644 index 0000000000..4f5c85d539 Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal008.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal010.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal010.webp new file mode 100644 index 0000000000..4adbad5fb8 Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal010.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal012.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal012.webp new file mode 100644 index 0000000000..fc528eb53a Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal012.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal014.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal014.webp new file mode 100644 index 0000000000..4fcb94ef98 Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal014.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal016.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal016.webp new file mode 100644 index 0000000000..f5a93b0804 Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal016.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal018.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal018.webp new file mode 100644 index 0000000000..02e0e93241 Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal018.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal020.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal020.webp new file mode 100644 index 0000000000..98e72da076 Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal020.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal022.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal022.webp new file mode 100644 index 0000000000..e2d81a7334 Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal022.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal024.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal024.webp new file mode 100644 index 0000000000..7a1b164bf8 Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal024.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal026.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal026.webp new file mode 100644 index 0000000000..5e6aaed2f8 Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal026.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal028.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal028.webp new file mode 100644 index 0000000000..6eb257211d Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal028.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal030.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal030.webp new file mode 100644 index 0000000000..a5edb81360 Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal030.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal032.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal032.webp new file mode 100644 index 0000000000..08c77712cb Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal032.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal034.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal034.webp new file mode 100644 index 0000000000..014091014e Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal034.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal036.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal036.webp new file mode 100644 index 0000000000..1cc0f71711 Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal036.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal038.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal038.webp new file mode 100644 index 0000000000..049594af92 Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal038.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal040.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal040.webp new file mode 100644 index 0000000000..b0a4fd1620 Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal040.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal042.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal042.webp new file mode 100644 index 0000000000..65dc7c66a7 Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal042.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal044.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal044.webp new file mode 100644 index 0000000000..007f0c5bd2 Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal044.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal046.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal046.webp new file mode 100644 index 0000000000..f64218b62e Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal046.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal048.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal048.webp new file mode 100644 index 0000000000..ce7aa5b09b Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal048.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal050.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal050.webp new file mode 100644 index 0000000000..2483b5cc85 Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal050.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal052.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal052.webp new file mode 100644 index 0000000000..2d6bbb3a28 Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal052.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal054.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal054.webp new file mode 100644 index 0000000000..073c631800 Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal054.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal056.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal056.webp new file mode 100644 index 0000000000..85ece9e86c Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal056.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal058.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal058.webp new file mode 100644 index 0000000000..8ea05e04c9 Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal058.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal060.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal060.webp new file mode 100644 index 0000000000..7128d98d60 Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal060.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal062.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal062.webp new file mode 100644 index 0000000000..05d022bc56 Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal062.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal064.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal064.webp new file mode 100644 index 0000000000..090a4dc753 Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal064.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal066.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal066.webp new file mode 100644 index 0000000000..ff190083fd Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal066.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal068.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal068.webp new file mode 100644 index 0000000000..0071c33280 Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal068.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal070.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal070.webp new file mode 100644 index 0000000000..b3fa5a1881 Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal070.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal072.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal072.webp new file mode 100644 index 0000000000..d5896737f6 Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal072.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal074.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal074.webp new file mode 100644 index 0000000000..7ff64b5711 Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal074.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal076.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal076.webp new file mode 100644 index 0000000000..ec56210221 Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal076.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal078.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal078.webp new file mode 100644 index 0000000000..e6ec711416 Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal078.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal080.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal080.webp new file mode 100644 index 0000000000..e8fa9e5d36 Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal080.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal082.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal082.webp new file mode 100644 index 0000000000..d8ef9b37a7 Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal082.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal084.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal084.webp new file mode 100644 index 0000000000..da08363a67 Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal084.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal086.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal086.webp new file mode 100644 index 0000000000..c496ae20cc Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal086.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal088.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal088.webp new file mode 100644 index 0000000000..27a41260df Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal088.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal090.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal090.webp new file mode 100644 index 0000000000..65f9302aed Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal090.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal092.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal092.webp new file mode 100644 index 0000000000..f7651dbf15 Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal092.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal094.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal094.webp new file mode 100644 index 0000000000..dd5570c9a9 Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal094.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal096.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal096.webp new file mode 100644 index 0000000000..4680be2c1c Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal096.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal098.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal098.webp new file mode 100644 index 0000000000..76723aa3f3 Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal098.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal100.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal100.webp new file mode 100644 index 0000000000..49969ff350 Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal100.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal102.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal102.webp new file mode 100644 index 0000000000..533855c47f Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal102.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal104.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal104.webp new file mode 100644 index 0000000000..ee31412bd6 Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal104.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal106.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal106.webp new file mode 100644 index 0000000000..8efe589ede Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal106.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal108.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal108.webp new file mode 100644 index 0000000000..1f6ff9aee6 Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal108.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal110.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal110.webp new file mode 100644 index 0000000000..3566c675d9 Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal110.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal112.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal112.webp new file mode 100644 index 0000000000..c9e23f1f69 Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal112.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal114.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal114.webp new file mode 100644 index 0000000000..be60094f54 Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal114.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal116.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal116.webp new file mode 100644 index 0000000000..e5dff07f9a Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal116.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal118.webp b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal118.webp new file mode 100644 index 0000000000..aba89b659b Binary files /dev/null and b/OCH/mogo-och-common-module/src/main/res/drawable/xiaozhi_normal118.webp differ diff --git a/OCH/mogo-och-common-module/src/main/res/values/arrays.xml b/OCH/mogo-och-common-module/src/main/res/values/arrays.xml new file mode 100644 index 0000000000..e939f34a83 --- /dev/null +++ b/OCH/mogo-och-common-module/src/main/res/values/arrays.xml @@ -0,0 +1,65 @@ + + + + @drawable/xiaozhi_normal002 + @drawable/xiaozhi_normal004 + @drawable/xiaozhi_normal006 + @drawable/xiaozhi_normal008 + @drawable/xiaozhi_normal010 + @drawable/xiaozhi_normal012 + @drawable/xiaozhi_normal014 + @drawable/xiaozhi_normal016 + @drawable/xiaozhi_normal018 + @drawable/xiaozhi_normal020 + @drawable/xiaozhi_normal022 + @drawable/xiaozhi_normal024 + @drawable/xiaozhi_normal026 + @drawable/xiaozhi_normal028 + @drawable/xiaozhi_normal030 + @drawable/xiaozhi_normal032 + @drawable/xiaozhi_normal034 + @drawable/xiaozhi_normal036 + @drawable/xiaozhi_normal038 + @drawable/xiaozhi_normal040 + @drawable/xiaozhi_normal042 + @drawable/xiaozhi_normal044 + @drawable/xiaozhi_normal046 + @drawable/xiaozhi_normal048 + @drawable/xiaozhi_normal050 + @drawable/xiaozhi_normal052 + @drawable/xiaozhi_normal054 + @drawable/xiaozhi_normal056 + @drawable/xiaozhi_normal058 + @drawable/xiaozhi_normal060 + @drawable/xiaozhi_normal062 + @drawable/xiaozhi_normal064 + @drawable/xiaozhi_normal066 + @drawable/xiaozhi_normal068 + @drawable/xiaozhi_normal070 + @drawable/xiaozhi_normal072 + @drawable/xiaozhi_normal074 + @drawable/xiaozhi_normal076 + @drawable/xiaozhi_normal078 + @drawable/xiaozhi_normal080 + @drawable/xiaozhi_normal082 + @drawable/xiaozhi_normal084 + @drawable/xiaozhi_normal086 + @drawable/xiaozhi_normal088 + @drawable/xiaozhi_normal090 + @drawable/xiaozhi_normal092 + @drawable/xiaozhi_normal094 + @drawable/xiaozhi_normal096 + @drawable/xiaozhi_normal098 + @drawable/xiaozhi_normal100 + @drawable/xiaozhi_normal102 + @drawable/xiaozhi_normal104 + @drawable/xiaozhi_normal106 + @drawable/xiaozhi_normal108 + @drawable/xiaozhi_normal110 + @drawable/xiaozhi_normal112 + @drawable/xiaozhi_normal114 + @drawable/xiaozhi_normal116 + @drawable/xiaozhi_normal118 + + + \ No newline at end of file diff --git a/OCH/taxi/unmanned-passenger/src/main/java/com/mogo/och/taxi/passenger/ui/TaxiPassengerBaseFragment.kt b/OCH/taxi/unmanned-passenger/src/main/java/com/mogo/och/taxi/passenger/ui/TaxiPassengerBaseFragment.kt index 50dad60f3c..02576728fa 100644 --- a/OCH/taxi/unmanned-passenger/src/main/java/com/mogo/och/taxi/passenger/ui/TaxiPassengerBaseFragment.kt +++ b/OCH/taxi/unmanned-passenger/src/main/java/com/mogo/och/taxi/passenger/ui/TaxiPassengerBaseFragment.kt @@ -72,12 +72,12 @@ class TaxiPassengerBaseFragment() : overMapView.onCreateView(savedInstanceState) overMapView.hideResetView() - createProgressDialogAnim = FrameAnimatorContainer(R.array.xiaozhi_normal, 20,aciv_xiaozhi_normal) - createProgressDialogAnim?.setOnAnimStopListener(object : FrameAnimatorContainer.OnAnimationStoppedListener{ - override fun AnimationStopped() { - CallerLogger.d(M_TAXI_P + TAG, "动画暂停") - } - }) +// createProgressDialogAnim = FrameAnimatorContainer(R.array.xiaozhi_normal, 20,aciv_xiaozhi_normal) +// createProgressDialogAnim?.setOnAnimStopListener(object : FrameAnimatorContainer.OnAnimationStoppedListener{ +// override fun AnimationStopped() { +// CallerLogger.d(M_TAXI_P + TAG, "动画暂停") +// } +// }) } private fun initListener() { diff --git a/OCH/taxi/unmanned-passenger/src/main/res/layout/taxi_p_base_fragment.xml b/OCH/taxi/unmanned-passenger/src/main/res/layout/taxi_p_base_fragment.xml index a8651e879a..4dbc188d3e 100644 --- a/OCH/taxi/unmanned-passenger/src/main/res/layout/taxi_p_base_fragment.xml +++ b/OCH/taxi/unmanned-passenger/src/main/res/layout/taxi_p_base_fragment.xml @@ -148,7 +148,7 @@ android:layout_height="@dimen/dp_160" app:layout_constraintBottom_toBottomOf="parent" /> - () + + fun addDistanceListener(tag: String, listener: ZhiRecordWinUi) { + if (mControllerStatusCallbackMap.containsKey(tag)) { + return + } + mControllerStatusCallbackMap[tag] = listener + } + + /** + * 删除监听 + * @param tag 标记,用来注销监听使用 + */ + fun removeListener(tag: String) { + mControllerStatusCallbackMap.remove(tag) + } + + fun isShowing():Boolean{ + return isShowing + } + + + fun dispatchStartEvent(reason:String){ + isShowing = true + mControllerStatusCallbackMap.forEach { + it.value.start(reason) + } + } + fun dispatchStatusChangeEvent(reason: ZhiRecordWinUi.RecordStatus){ + mControllerStatusCallbackMap.forEach { + it.value.onStatusChange(reason) + } + } + fun dispatchCloseEvent(trigger:Boolean){ + isShowing = false + mControllerStatusCallbackMap.forEach { + it.value.close(trigger) + } + } + + fun dispatchOnVolumeChangeEvent(volume:Int){ + mControllerStatusCallbackMap.forEach { + it.value.onVolumeChange(volume) + } + } + fun dispatchShowInputTextEvent(reason: AsrTextBean){ + mControllerStatusCallbackMap.forEach { + it.value.showInputText(reason) + } + } + + @Suppress("UNUSED_PARAMETER") + fun dispatchShowOutPutWidgetEvent(callbackWidget: CallbackWidget){ + mControllerStatusCallbackMap.forEach { + it.value.showOutPutWidget(null) + } + } + fun dispatchShowOutputTextEvent(reason: String){ + if (!isShowing) { + return + } + mControllerStatusCallbackMap.forEach { + it.value.showOutputText(reason) + } + } + +} \ No newline at end of file diff --git a/tts/tts-base/src/main/java/com/mogo/tts/base/zhi/CallbackWidget.java b/tts/tts-base/src/main/java/com/mogo/tts/base/zhi/CallbackWidget.java new file mode 100644 index 0000000000..f5d75a2602 --- /dev/null +++ b/tts/tts-base/src/main/java/com/mogo/tts/base/zhi/CallbackWidget.java @@ -0,0 +1,53 @@ +package com.mogo.tts.base.zhi; + +import android.text.TextUtils; + +import org.json.JSONArray; +import org.json.JSONObject; + +public class CallbackWidget { + public int type; + public String intentName; + public String skillId; + public String taskName; + public JSONArray recommendations; + public JSONObject extra; + + public CallbackWidget() { + + } + + protected CallbackWidget(JSONObject var1, int var2, String var3, String var4, String var5) { + this.type = var2; + this.intentName = var5; + this.skillId = var3; + this.taskName = var4; + this.recommendations = var1.optJSONArray("recommendations"); + this.extra = var1.optJSONObject("extra"); + } + + public String getIntentName() { + return this.intentName; + } + + public String getSkillId() { + return this.skillId; + } + + public String getTaskName() { + return this.taskName; + } + + public JSONArray getRecommendations() { + return this.recommendations; + } + + public JSONObject getExtra() { + return this.extra; + } + + public int getType() { + return this.type; + } + +} diff --git a/tts/tts-base/src/main/java/com/mogo/tts/base/zhi/ZhiRecordWinUi.java b/tts/tts-base/src/main/java/com/mogo/tts/base/zhi/ZhiRecordWinUi.java new file mode 100644 index 0000000000..2fcd0aadbf --- /dev/null +++ b/tts/tts-base/src/main/java/com/mogo/tts/base/zhi/ZhiRecordWinUi.java @@ -0,0 +1,60 @@ +package com.mogo.tts.base.zhi; + +public interface ZhiRecordWinUi { + + /** + * 开始对话 + * + * @param reason + */ + void start(String reason); + + /** + * 语音卡状态变化 + * + * @param status + */ + void onStatusChange(RecordStatus status); + + /** + * 关闭对话 + * @param trigger 是否手动 + */ + void close(boolean trigger); + + /** + * 语音输入音量变化 + * + * @param volume + */ + void onVolumeChange(int volume); + + /** + * 显示用户输入的内容 + * + * @param asrTextBean + */ + void showInputText(AsrTextBean asrTextBean); + + /** + * 显示控件 暂时没有需求 + * + * @param callbackWidget + */ + void showOutPutWidget(CallbackWidget callbackWidget); + + /** + * 显示系统输出内容 + * + * @param outPutText + */ + void showOutputText(String outPutText); + + enum RecordStatus { + STATUS_SILENCE, + STATUS_LISTENING, + STATUS_UNDERSTANDING, + STATUS_UNDERSTAND_END, + STATUS_SPEAKING + } +} diff --git a/tts/tts-zhi/build.gradle b/tts/tts-zhi/build.gradle index 13499b22f0..78c3ba5cb5 100644 --- a/tts/tts-zhi/build.gradle +++ b/tts/tts-zhi/build.gradle @@ -47,7 +47,8 @@ dependencies { kapt rootProject.ext.dependencies.aroutercompiler api rootProject.ext.dependencies.aiassist - api rootProject.ext.dependencies.aiassistReplace + implementation rootProject.ext.dependencies.aiassistReplace + implementation rootProject.ext.dependencies.androidxrecyclerview if (Boolean.valueOf(USE_MAVEN_PACKAGE)) { implementation rootProject.ext.dependencies.ttsbase @@ -56,6 +57,11 @@ dependencies { implementation project(":tts:tts-base") implementation project(':core:mogo-core-utils') } + +// implementation project(":xiaozhisdk") + implementation 'com.zhidao.speech.adapter:speechadapter:1.0.0-SNAPSHOT' + implementation 'com.mogo.xiaozhi.sdk:xiaozhisdk:1.0.0-SNAPSHOT' + } apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString() \ No newline at end of file diff --git a/tts/tts-zhi/src/main/AndroidManifest.xml b/tts/tts-zhi/src/main/AndroidManifest.xml index 70631ddf64..c9bed99b00 100644 --- a/tts/tts-zhi/src/main/AndroidManifest.xml +++ b/tts/tts-zhi/src/main/AndroidManifest.xml @@ -1,5 +1,94 @@ - / + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tts/tts-zhi/src/main/java/com/mogo/tts/pad/ZhiAvatarWindow.java b/tts/tts-zhi/src/main/java/com/mogo/tts/pad/ZhiAvatarWindow.java new file mode 100644 index 0000000000..6953894453 --- /dev/null +++ b/tts/tts-zhi/src/main/java/com/mogo/tts/pad/ZhiAvatarWindow.java @@ -0,0 +1,243 @@ +package com.mogo.tts.pad; + +import android.animation.Animator; +import android.graphics.drawable.AnimationDrawable; +import android.graphics.drawable.Drawable; +import android.util.Log; +import android.view.animation.AccelerateDecelerateInterpolator; +import android.widget.ImageView; +import android.widget.TextView; + + +import com.aispeech.export.widget.callback.CallbackWidget; +import com.aispeech.export.widget.callback.CallbackWidgetType; +import com.aispeech.export.widget.callback.CustomCallbackWidget; +import com.aispeech.export.widget.callback.ListCallbackWidget; +import com.aispeech.upload.util.LogUtil; +import com.mogo.tts.base.zhi.AvatarManager; +import com.mogo.tts.base.zhi.ZhiRecordWinUi; +import com.mogo.xiaozhi.sdk.analytics.AnalyticsConst; +import com.mogo.xiaozhi.sdk.bean.AsrTextBean; +import com.mogo.xiaozhi.sdk.engine.cdm.AICloudDManager; +import com.mogo.xiaozhi.sdk.engine.tts.AILocalTTS; +import com.mogo.xiaozhi.sdk.ui.dui.RecordWinUi; +import com.mogo.xiaozhi.sdk.utils.AnalyticsUtil; +import java.text.SimpleDateFormat; +import java.util.HashMap; +import java.util.Map; + +/** + * Created by pangfan on 2020/12/14 + */ +public class ZhiAvatarWindow implements RecordWinUi { + private static final String TAG = ZhiAvatarWindow.class.getSimpleName(); + + + private ImageView leftImageView; + private TextView mNormalChatTextView; + + + private boolean flagWeather = false; + private boolean isLeftImageShowingWeather = false; + + public ZhiAvatarWindow() { + } + + @Override + protected void finalize() throws Throwable { + super.finalize(); + Log.d(TAG, "finalize"); + } + + @Override + public boolean isSpeeching() { + return AvatarManager.INSTANCE.isShowing(); + } + + @Override + public void start(String reason) { + trackAwakeEvent(); + if(AvatarManager.INSTANCE.isShowing()) { + AILocalTTS.getInstance().setIsForbidASR(false); + } + AvatarManager.INSTANCE.dispatchStartEvent(reason); + } + + @Override + public void onStatusChange(RecordStatus status) { + Log.d(TAG, "onStatusChange status = " + status); + if (status== RecordStatus.STATUS_SILENCE) { + AvatarManager.INSTANCE.dispatchStatusChangeEvent(ZhiRecordWinUi.RecordStatus.STATUS_UNDERSTANDING); + }else if(status== RecordStatus.STATUS_LISTENING) { + AvatarManager.INSTANCE.dispatchStatusChangeEvent(ZhiRecordWinUi.RecordStatus.STATUS_LISTENING); + }else if(status== RecordStatus.STATUS_UNDERSTANDING) { + AvatarManager.INSTANCE.dispatchStatusChangeEvent(ZhiRecordWinUi.RecordStatus.STATUS_UNDERSTANDING); + }else if(status== RecordStatus.STATUS_UNDERSTAND_END) { + AvatarManager.INSTANCE.dispatchStatusChangeEvent(ZhiRecordWinUi.RecordStatus.STATUS_UNDERSTAND_END); + }else if(status== RecordStatus.STATUS_SPEAKING) { + AvatarManager.INSTANCE.dispatchStatusChangeEvent(ZhiRecordWinUi.RecordStatus.STATUS_SPEAKING); + } + +// if (status == RecordStatus.STATUS_LISTENING) {// 听取中 +// if (flagWeather) { +// flagWeather = false; +// mNormalChatTextView.setText(""); +// return; +// } +// if (isLeftImageShowingWeather) { +// isLeftImageShowingWeather = false; +// } +// showIconAnimation(status); +// } else if (status == RecordStatus.STATUS_UNDERSTANDING) { +// if (isLeftImageShowingWeather) { +// isLeftImageShowingWeather = false; +// } +// showIconAnimation(status); +// } else if (status == RecordStatus.STATUS_SPEAKING) { +// if (flagWeather) { +// flagWeather = false; +// return; +// } +// if (isLeftImageShowingWeather) { +// isLeftImageShowingWeather = false; +// } else { +// showIconAnimation(status); +// } +// } + } + + @Override + public void close(boolean trigger) { + Log.i(TAG, "close: trigger = $trigger"); + if (trigger) { + AICloudDManager.getInstance().stop(); + } + AILocalTTS.getInstance().setIsForbidASR(false); + AvatarManager.INSTANCE.dispatchCloseEvent(trigger); + } + + @Override + public void onVolumeChange(int volume) { + AvatarManager.INSTANCE.dispatchOnVolumeChangeEvent(volume); + } + + @Override + public void showOutPutWidget(CallbackWidget callbackWidget) { + if (callbackWidget == null) return; + + if (CallbackWidgetType.CUSTOM.getType() == callbackWidget.getType()) { + CustomCallbackWidget customCallbackWidget = (CustomCallbackWidget) callbackWidget; + //showCustomWidget(customCallbackWidget); + Log.w(TAG, "天气支持"); + } else if (CallbackWidgetType.LIST.getType() == callbackWidget.getType()) { + ListCallbackWidget listCallbackWidget = (ListCallbackWidget) callbackWidget; + Log.w(TAG, "暂不支持列表"); + } + AvatarManager.INSTANCE.dispatchShowOutPutWidgetEvent(new com.mogo.tts.base.zhi.CallbackWidget()); + } + + @Override + public void showInputText(AsrTextBean asrTextBean) { + if (asrTextBean == null) return; + AvatarManager.INSTANCE.dispatchShowInputTextEvent( + new com.mogo.tts.base.zhi.AsrTextBean(asrTextBean.isLast(),asrTextBean.getText())); + } + + @Override + public void showOutputText(String outPutText) { + AvatarManager.INSTANCE.dispatchShowOutputTextEvent(outPutText); + } + + private void showIconAnimation(RecordStatus status) { + LogUtil.d(TAG, "status = " + status); + switch (status) { + case STATUS_LISTENING: + playAnimation(leftImageView, R.drawable.anim_voice_listening); + break; + case STATUS_UNDERSTANDING: + playAnimation(leftImageView, R.drawable.anim_voice_loading); + case STATUS_SPEAKING: + playAnimation(leftImageView, R.drawable.anim_voice_speaking); + break; + } + } + + /** + * 播放动画 + * 如果当前是天气图片,直接返回; + * + * @param chatIconView 需要播放动画的 ImageView + * @param resourceId 需要播放动画的ImageView 的 Animation Drawable. + */ + private void playAnimation(final ImageView chatIconView, final int resourceId) { + chatIconView.setImageResource(resourceId); + if (isLeftImageShowingWeather) { + LogUtil.d(TAG, "weather icon, not animation."); + return; + } + + // stop current animation first. + Drawable animDrawable = chatIconView.getDrawable(); + if (!(animDrawable instanceof AnimationDrawable)) { + LogUtil.e(TAG, "chatIconView should have a AnimationDrawable"); + return; + } + AnimationDrawable anim = (AnimationDrawable) animDrawable; + anim.stop(); + chatIconView.animate() + .scaleX(0f) + .scaleY(0f) + .setDuration(100) + .setInterpolator(new AccelerateDecelerateInterpolator()) + .setListener(new AnimationEndListener() { + @Override + public void onAnimationEnd(Animator animation) { + chatIconView.setImageResource(resourceId); + chatIconView.setAlpha(0f); + chatIconView.setScaleX(0f); + chatIconView.setScaleY(0f); + chatIconView.animate() + .alpha(1f) + .scaleX(1f) + .scaleY(1f) + .setInterpolator(new AccelerateDecelerateInterpolator()) + .setDuration(100) + .setListener(new AnimationEndListener() { + @Override + public void onAnimationEnd(Animator animation) { + AnimationDrawable anim = (AnimationDrawable) chatIconView.getDrawable(); + anim.start(); + } + }) + .start(); + } + }) + .start(); + } + + /** + * only onAnimationEnd is required here. other call back is empty. + */ + abstract static class AnimationEndListener implements Animator.AnimatorListener { + @Override + public void onAnimationStart(Animator animation) { + } + + @Override + public void onAnimationCancel(Animator animation) { + } + + @Override + public void onAnimationRepeat(Animator animation) { + } + } + + private void trackAwakeEvent() { + SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); + String time = dateformat.format(System.currentTimeMillis()); + Map eventMap = new HashMap<>(); + eventMap.put(AnalyticsConst.Key.KEY_SESSION_START_TIME, time); + AnalyticsUtil.trackNormalEvent(AnalyticsConst.Event.XIAOZHI_AWAKE, eventMap); + } + +} diff --git a/tts/tts-zhi/src/main/java/com/mogo/tts/pad/ZhiTTS.java b/tts/tts-zhi/src/main/java/com/mogo/tts/pad/ZhiTTS.java index c8385b0a3c..3cd1fd5eb0 100644 --- a/tts/tts-zhi/src/main/java/com/mogo/tts/pad/ZhiTTS.java +++ b/tts/tts-zhi/src/main/java/com/mogo/tts/pad/ZhiTTS.java @@ -1,95 +1,70 @@ package com.mogo.tts.pad; import android.content.Context; -import android.content.Intent; -import android.text.TextUtils; +import android.os.Build; +import android.provider.Settings; +import android.util.Pair; -import com.alibaba.android.arouter.facade.annotation.Route; -import com.mogo.eagle.core.utilcode.util.AppUtils; +import androidx.annotation.MainThread; + +import com.elegant.utils.storage.SharedPrefsMgr; +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; import com.mogo.tts.base.IMogoTTS; import com.mogo.tts.base.IMogoTTSCallback; -import com.mogo.tts.base.MogoTTSConstants; +import com.mogo.tts.base.MultiLangTtsEntity; import com.mogo.tts.base.PreemptType; - +import com.mogo.xiaozhi.sdk.engine.DMStatusListener; +import com.mogo.xiaozhi.sdk.engine.RecorderDMManager; +import com.mogo.xiaozhi.sdk.module.show.ZDCloudDMManager; import com.zhidao.auto.platform.voice.VoiceClient; -import com.zhidao.voicesdk.MogoVoiceManager; -import com.zhidao.voicesdk.MogoVoiceManagerImpl; -import com.zhidao.voicesdk.callback.OnConnStatusListener; +import com.zhidao.speech.adapter.AdapterApp; import com.zhidao.voicesdk.callback.OnTtsListener; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; +import java.util.LinkedList; -public /** * @author congtaowang * @since 2020/10/12 *

- * 描述 */ -@Route( path = MogoTTSConstants.API_PATH ) -class ZhiTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsListener { +//@Route(path = MogoTTSConstants.API_PATH) +public class ZhiTTS implements IMogoTTS, OnTtsListener { private static final String TAG = "ZhiTTS"; - private String mLastQAndASpeakText; - private boolean mHasFlush = false; - private boolean mInitReady = false; private Context mContext; - public synchronized void release() { - if ( mCmdMap != null && !mCmdMap.isEmpty() && mVoiceClient != null ) { - for ( String cmd : mCmdMap.keySet() ) { - try { - mVoiceClient.unRegisterCustomWakeupCmd( cmd ); - } catch ( Exception e ) { - } + public void release() { + CallerLogger.d(TAG, "release"); + } + + + @Override + public void initTts(String sn) { + CallerLogger.d(TAG, "initTts"); + AdapterApp.getInstance().init(mContext); + + ZDCloudDMManager.getInstance().setUIView(ZhiAvatarWindow.class); + + RecorderDMManager.getInstance().registerListener(new DMStatusListener() { + @Override + public void onInitSuccess() { + CallerLogger.d(TAG, "RecorderDMManager---onInitSuccess"); } - } - mQAndAMap.clear(); - mVoiceClient.release(); - mSpeakVoiceMap.clear(); - mCacheUnWakeupCommands.clear(); - mContext = null; + + @Override + public void onError(int code, String info) { + CallerLogger.d(TAG, "RecorderDMManager---onError---code"+code+"--info"+info); + } + }); } - private VoiceClient mVoiceClient; - private MogoVoiceManager mogoVoiceManager; - // 免唤醒指令 - private Map< String, List< IMogoTTSCallback > > mCmdMap = new HashMap<>(); - // 问答指令 - private Map< String, IMogoTTSCallback > mQAndAMap = new HashMap<>(); - // 单独的语音播放 - private Map< String, IMogoTTSCallback > mSpeakVoiceMap = new HashMap<>(); - - private Map< String, String[] > mCacheUnWakeupCommands = new ConcurrentHashMap<>(); - - private void initFlushStatus() { - if ( !mHasFlush ) { - mHasFlush = isVoiceServiceReady( mContext ); - } - } /** * 初始化 */ - private void initSpeech( Context context ) { - mogoVoiceManager = MogoVoiceManagerImpl.getInstance(); - mogoVoiceManager.init( context, new OnConnStatusListener() { - @Override - public void onSuccess() { - mInitReady = true; - } - - @Override - public void onFailed() { - - } - } ); + private void initSpeech(Context context) { + CallerLogger.d(TAG, "initSpeech"); } /** @@ -99,82 +74,8 @@ class ZhiTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsListener { */ @Override public boolean hasFlush() { - return mHasFlush; - } - - @Override - public void onCmdSelected( String cmd ) { - if ( !mCmdMap.containsKey( cmd ) ) { - return; - } - - Iterator< IMogoTTSCallback > iterator = null; - try { - List< IMogoTTSCallback > cmdCallBacks = mCmdMap.get( cmd ); - iterator = new ArrayList<>( cmdCallBacks ).iterator(); - } catch ( Exception e ) { - - } - while ( iterator != null && iterator.hasNext() ) { - IMogoTTSCallback callBack = iterator.next(); - if ( callBack != null ) { - callBack.onCmdSelected( cmd ); - } - } - } - - @Override - public void onCmdAction( String speakText ) { - if ( !TextUtils.isEmpty( mLastQAndASpeakText ) ) { - IMogoTTSCallback cmdCallBack = mQAndAMap.remove( mLastQAndASpeakText ); - if ( cmdCallBack != null ) { - cmdCallBack.onCmdAction( speakText ); - } - } - } - - @Override - public void onCmdCancel( String speakText ) { - if ( !TextUtils.isEmpty( mLastQAndASpeakText ) ) { - IMogoTTSCallback cmdCallBack = mQAndAMap.remove( mLastQAndASpeakText ); - if ( cmdCallBack != null ) { - cmdCallBack.onCmdCancel( speakText ); - } - } - } - - @Override - public void onSpeakEnd( String speakText ) { - if ( mQAndAMap.containsKey( speakText ) ) { - mLastQAndASpeakText = speakText; - IMogoTTSCallback cmdCallBack = mQAndAMap.get( speakText ); - if ( cmdCallBack != null ) { - cmdCallBack.onSpeakEnd( speakText ); - return; - } - } - IMogoTTSCallback callBack = mSpeakVoiceMap.remove( speakText ); - if ( callBack != null ) { - callBack.onSpeakEnd( speakText ); - } - } - - @Override - public void onSpeakSelectTimeOut( String speakText ) { - if ( mQAndAMap.containsKey( speakText ) ) { - if ( TextUtils.equals( speakText, mLastQAndASpeakText ) ) { - mLastQAndASpeakText = null; - } - IMogoTTSCallback cmdCallBack = mQAndAMap.remove( speakText ); - if ( cmdCallBack != null ) { - cmdCallBack.onSpeakSelectTimeOut( speakText ); - return; - } - } - IMogoTTSCallback callBack = mSpeakVoiceMap.remove( speakText ); - if ( callBack != null ) { - callBack.onSpeakSelectTimeOut( speakText ); - } + CallerLogger.d(TAG, "hasFlush"); + return true; } /** @@ -182,15 +83,16 @@ class ZhiTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsListener { * * @param text */ - public void speakTTSVoice( String text, IMogoTTSCallback callBack ) { - try { - initFlushStatus(); - if ( mHasFlush ) { - mSpeakVoiceMap.put( text, callBack ); - mVoiceClient.speakDefault( text ); - } - } catch ( Exception e ) { - } + public void speakTTSVoice(String text, IMogoTTSCallback callBack) { + CallerLogger.d(TAG, "speakTTSVoice"); + } + + public void stopSpeakTts(String text) { + CallerLogger.d(TAG, "text"); + } + + public void stopTts() { + CallerLogger.d(TAG, "stopTts"); } /** @@ -198,48 +100,35 @@ class ZhiTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsListener { * * @param text */ - public void speakTTSVoice( String text ) { - try { - initFlushStatus(); - if ( mHasFlush ) { - mVoiceClient.speakDefault( text ); - } - } catch ( Exception e ) { - } + public void speakTTSVoice(String text) { + CallerLogger.d(TAG, "speakTTSVoice"); } + @MainThread + public void speakTTSVoiceWithLevel(String text, int ttsLevel) { + CallerLogger.d(TAG, "speakTTSVoiceWithLevel"); + } + + @MainThread + public void speakTTSVoiceWithLevel(String text, int ttsLevel, IMogoTTSCallback callBack) { + CallerLogger.d(TAG, "speakTTSVoiceWithLevel"); + } + + + /** * 语音播报 * * @param text 播报内容 * @param type 播报策略 */ - public void speakTTSVoice( String text, PreemptType type, IMogoTTSCallback callBack ) { - try { - initFlushStatus(); - if ( mHasFlush ) { - mSpeakVoiceMap.put( text, callBack ); - VoiceClient.PreemptType preemptType = VoiceClient.PreemptType.PREEMPT_TYPE_NONE; - if ( type != null ) { - switch ( type ) { - case PREEMPT_TYPE_NEXT: - preemptType = VoiceClient.PreemptType.PREEMPT_TYPE_NEXT; - break; - case PREEMPT_TYPE_FLUSH: - preemptType = VoiceClient.PreemptType.PREEMPT_TYPE_FLUSH; - break; - case PREEMPT_TYPE_IMMEDIATELY: - preemptType = VoiceClient.PreemptType.PREEMPT_TYPE_IMMEADIATELY; - break; - case PREEMPT_TYPE_IMMEDIATELY_WITHOUT_CANCEL: - preemptType = VoiceClient.PreemptType.PREEMPT_TYPE_IMMEADIATELY_WITHOUT_CANCLE; - break; - } - } - mVoiceClient.speakTypeText( text, preemptType ); - } - } catch ( Exception e ) { - } + public void speakTTSVoice(String text, PreemptType type, IMogoTTSCallback callBack) { + CallerLogger.d(TAG, "speakTTSVoice"); + } + + @Override + public void speakMultiLangTTSWithLevel(MultiLangTtsEntity ttsEntity, int level, IMogoTTSCallback callback) { + CallerLogger.d(TAG, "speakMultiLangTTSWithLevel"); } /** @@ -247,12 +136,8 @@ class ZhiTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsListener { * * @param tts 播报内容 */ - public void speakQAndACmd( String tts, IMogoTTSCallback callBack ) { - initFlushStatus(); - if ( mHasFlush ) { - mQAndAMap.put( tts, callBack ); - mVoiceClient.speakTtsAndRegistCmd( tts ); - } + public void speakQAndACmd(String tts, IMogoTTSCallback callBack) { + CallerLogger.d(TAG, "speakQAndACmd"); } /** @@ -262,12 +147,8 @@ class ZhiTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsListener { * @param okCmds 确认命令唤醒词 * @param cancelCmds 取消命令唤醒词 */ - public void speakQAndACmd( String tts, String[] okCmds, String[] cancelCmds, IMogoTTSCallback callBack ) { - initFlushStatus(); - if ( mHasFlush ) { - mQAndAMap.put( tts, callBack ); - mVoiceClient.speakTtsAndRegistCmd( tts, okCmds, cancelCmds ); - } + public void speakQAndACmd(String tts, String[] okCmds, String[] cancelCmds, IMogoTTSCallback callBack) { + CallerLogger.d(TAG, "speakQAndACmd"); } /** @@ -277,33 +158,8 @@ class ZhiTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsListener { * @param cmdWords * @param callBack */ - public void registerUnWakeupCommand( String cmd, String[] cmdWords, IMogoTTSCallback callBack ) { - if ( !mCmdMap.containsKey( cmd ) ) { - mCmdMap.put( cmd, new ArrayList<>() ); - } - mCmdMap.get( cmd ).add( callBack ); - - initFlushStatus(); - if ( mHasFlush ) { - mVoiceClient.registerCustomWakeupCmd( cmd, cmdWords ); - mCacheUnWakeupCommands.remove( cmd ); - } - mCacheUnWakeupCommands.put( cmd, cmdWords ); - } - - /** - * 注册免唤醒命令 - * - * @param cmd - * @param cmdWords - */ - private void registerUnWakeupCommand( String cmd, String[] cmdWords ) { - initFlushStatus(); - if ( mHasFlush ) { - mVoiceClient.registerCustomWakeupCmd( cmd, cmdWords ); - mCacheUnWakeupCommands.remove( cmd ); - } - mCacheUnWakeupCommands.put( cmd, cmdWords ); + public void registerUnWakeupCommand(String cmd, String[] cmdWords, IMogoTTSCallback callBack) { + CallerLogger.d(TAG, "registerUnWakeupCommand"); } /** @@ -311,13 +167,8 @@ class ZhiTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsListener { * * @param cmd */ - public synchronized void unregisterUnWakeupCommand( String cmd ) { - mCmdMap.remove( cmd ); - try { - mVoiceClient.unRegisterCustomWakeupCmd( cmd ); - } catch ( Exception e ) { - } - mCacheUnWakeupCommands.remove( cmd ); + public synchronized void unregisterUnWakeupCommand(String cmd) { + CallerLogger.d(TAG, "unregisterUnWakeupCommand"); } /** @@ -325,83 +176,26 @@ class ZhiTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsListener { * * @param cmd */ - public synchronized void unregisterUnWakeupCommand( String cmd, IMogoTTSCallback callBack ) { - if ( mCmdMap.containsKey( cmd ) ) { - List< IMogoTTSCallback > callBacks = mCmdMap.get( cmd ); - if ( callBacks != null ) { - callBacks.remove( callBack ); - } - if ( callBacks.isEmpty() ) { - mCmdMap.remove( cmd ); - try { - mVoiceClient.unRegisterCustomWakeupCmd( cmd ); - } catch ( Exception e ) { - } - mCacheUnWakeupCommands.remove( cmd ); - } - } + public synchronized void unregisterUnWakeupCommand(String cmd, IMogoTTSCallback callBack) { + CallerLogger.d(TAG, "unregisterUnWakeupCommand"); } - public static void startAssistant( Context context ) { - startAssistant( context, 1 ); - } - - /** - * @param context - * @param status window_start_cancel 0 - 结束, 1 - 显示, 2 - 未激活调试进入 - */ - public static void startAssistant( Context context, int status ) { - final Intent intent = new Intent(); - intent.setFlags( Intent.FLAG_INCLUDE_STOPPED_PACKAGES ); - intent.setAction( "pvetec.intent.action.txz.switch" ); - intent.putExtra( "window_start_cancel", status ); - intent.putExtra( "extra_switch_type", "window_start_cancel" ); - context.sendBroadcast( intent ); - } public synchronized void flush() { - if ( mCacheUnWakeupCommands.isEmpty() ) { - return; - } - mHasFlush = true; - final Map< String, String[] > tmp = new HashMap<>( mCacheUnWakeupCommands ); - for ( String cmd : tmp.keySet() ) { - registerUnWakeupCommand( cmd, tmp.get( cmd ) ); - } + CallerLogger.d(TAG, "flush"); } - private boolean isVoiceServiceReady( Context context ) { - if ( AppUtils.isProcessRunning( context, AppUtils.getPackageUid( context, "com.zhidao.speech" ) ) - && AppUtils.isProcessRunning( context, AppUtils.getPackageUid( context, "com.zhidao.speech.adapter" ) ) ) { - return true; - } else if ( AppUtils.isProcessRunning( context, AppUtils.getPackageUid( context, "com.txznet.txz" ) ) - && AppUtils.isProcessRunning( context, AppUtils.getPackageUid( context, "com.txznet.adapter" ) ) ) { - return true; - } - return false; + + public void speakTTSAndDuck(String text) { + CallerLogger.d(TAG, "speakTTSAndDuck"); } - public void speakTTSAndDuck( String text ) { - speakTTSAndDuck( text, null ); + public void speakTTSAndDuck(String text, IMogoTTSCallback callBack) { + CallerLogger.d(TAG, "speakTTSAndDuck"); } - public void speakTTSAndDuck( String text, IMogoTTSCallback callBack ) { - try { - if ( mInitReady ) { - mSpeakVoiceMap.put( text, callBack ); - mogoVoiceManager.toSpeak( text, -3, this ); - } - } catch ( Exception e ) { - } - } - - public void shutUp( String ttsId, String text ) { - try { - mSpeakVoiceMap.remove( text ); - mogoVoiceManager.shutUp( ttsId ); - } catch ( Exception e ) { - - } + public void shutUp(String ttsId, String text) { + CallerLogger.d(TAG, "shutUp"); } /** @@ -409,64 +203,54 @@ class ZhiTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsListener { * 语音SDK生效版本从1.0.8.4版本起 */ public void breakOffSpeak() { - mVoiceClient.breakOffSpeak(); + CallerLogger.d(TAG, "breakOffSpeak"); } - public void clearTTSCallback( String text ) { - try { - mSpeakVoiceMap.remove( text ); - } catch ( Exception e ) { - e.printStackTrace(); - } + public void clearTTSCallback(String text) { + CallerLogger.d(TAG, "clearTTSCallback"); } @Override - public void onTtsStart( String ttsId, String text ) { - IMogoTTSCallback callBack = mSpeakVoiceMap.get( text ); - if ( callBack != null ) { - callBack.onTTSStart( ttsId, text ); - } + public void onTtsStart(String ttsId, String text) { + CallerLogger.d(TAG, "onTtsStart"); } @Override - public void onTtsFinish( String ttsId, String text ) { - IMogoTTSCallback callBack = mSpeakVoiceMap.remove( text ); - if ( callBack != null ) { - callBack.onTTSEnd( ttsId, text ); - } + public void onTtsFinish(String ttsId, String text) { + CallerLogger.d(TAG, "onTtsFinish"); } @Override - public void onTtsError( String ttsId, String text ) { - IMogoTTSCallback callBack = mSpeakVoiceMap.remove( text ); - if ( callBack != null ) { - callBack.onTTSError( ttsId, text ); - } + public void onTtsError(String ttsId, String text) { + CallerLogger.d(TAG, "onTtsError"); } @Override - public void init( Context context ) { - if ( context != null ) { + public void init(Context context) { + CallerLogger.d(TAG, "onTtsError"); + if (context != null) { mContext = context.getApplicationContext(); - mVoiceClient = new VoiceClient( mContext ); - mVoiceClient.setCallBack( this ); - initFlushStatus(); - initSpeech( context ); + + initTts(SharedPrefsMgr.getInstance(mContext).getString("sn")); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + // 检查是否有悬浮窗权限 + if (Settings.canDrawOverlays(context)) { + initSpeech(context); + } + } else { + initSpeech(context); + } } } @Override - public void startAIAssist( Context context ) { - startAssistant( context, 1 ); + public void startAIAssist(Context context) { + } @Override - public void startAIAssist( Context context, int status ) { - final Intent intent = new Intent(); - intent.setFlags( Intent.FLAG_INCLUDE_STOPPED_PACKAGES ); - intent.setAction( "pvetec.intent.action.txz.switch" ); - intent.putExtra( "window_start_cancel", status ); - intent.putExtra( "extra_switch_type", "window_start_cancel" ); - context.sendBroadcast( intent ); + public void startAIAssist(Context context, int status) { + } + } diff --git a/tts/tts-zhi/src/main/res/layout/tts_zhi_layout.xml b/tts/tts-zhi/src/main/res/layout/tts_zhi_layout.xml new file mode 100644 index 0000000000..383fb6f946 --- /dev/null +++ b/tts/tts-zhi/src/main/res/layout/tts_zhi_layout.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + diff --git a/tts/tts-zhi/src/main/res/values/string.xml b/tts/tts-zhi/src/main/res/values/string.xml new file mode 100644 index 0000000000..3c3e14b786 --- /dev/null +++ b/tts/tts-zhi/src/main/res/values/string.xml @@ -0,0 +1,4 @@ + + + 278586132 + \ No newline at end of file