diff --git a/OCH/taxi/unmanned-passenger/src/main/java/com/mogo/och/unmanned/passenger/TaxiUnmannedPassengerProvider.kt b/OCH/taxi/unmanned-passenger/src/main/java/com/mogo/och/unmanned/passenger/TaxiUnmannedPassengerProvider.kt index 6bb7c536ba..8cbc82d45a 100644 --- a/OCH/taxi/unmanned-passenger/src/main/java/com/mogo/och/unmanned/passenger/TaxiUnmannedPassengerProvider.kt +++ b/OCH/taxi/unmanned-passenger/src/main/java/com/mogo/och/unmanned/passenger/TaxiUnmannedPassengerProvider.kt @@ -7,6 +7,7 @@ import com.alibaba.android.arouter.facade.annotation.Route import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant import com.mogo.mgintelligent.speech.MGSpeech +import com.mogo.mgintelligent.speech.iflytek.WakeManager import com.mogo.och.common.module.constant.OchCommonConst import com.mogo.och.common.module.biz.provider.CommonServiceImpl import com.mogo.och.bridge.autopilot.autopilot.OchAutopilotAnalytics @@ -32,6 +33,7 @@ class TaxiUnmannedPassengerProvider : CommonServiceImpl() { d(SceneConstant.M_TAXI_P + tag, "init") statusBarView = StatusBarView(context) MGSpeech.init(context) + WakeManager.initWakeAi(context) } override fun getStatusBarView(context: Context): View { diff --git a/libraries/mogo-speech/build.gradle b/libraries/mogo-speech/build.gradle index 449ad99f39..a68effdbc6 100644 --- a/libraries/mogo-speech/build.gradle +++ b/libraries/mogo-speech/build.gradle @@ -57,4 +57,9 @@ dependencies { implementation(files("libs/bdasr_V3_20210628_cfe8c44.jar")) implementation(files("libs/com.baidu.tts_2.6.3.c2aaa9f_20220922113422.jar")) + + implementation files('libs/AIKit.aar') + + implementation project(':foudations:mogo-commons') + implementation project(':core:mogo-core-utils') } diff --git a/libraries/mogo-speech/libs/AIKit.aar b/libraries/mogo-speech/libs/AIKit.aar new file mode 100644 index 0000000000..affa3acb71 Binary files /dev/null and b/libraries/mogo-speech/libs/AIKit.aar differ diff --git a/libraries/mogo-speech/src/main/assets/ivw/IVW_FILLER_1 b/libraries/mogo-speech/src/main/assets/ivw/IVW_FILLER_1 new file mode 100644 index 0000000000..2e359c96a4 Binary files /dev/null and b/libraries/mogo-speech/src/main/assets/ivw/IVW_FILLER_1 differ diff --git a/libraries/mogo-speech/src/main/assets/ivw/IVW_GRAM_1 b/libraries/mogo-speech/src/main/assets/ivw/IVW_GRAM_1 new file mode 100644 index 0000000000..1a16691776 Binary files /dev/null and b/libraries/mogo-speech/src/main/assets/ivw/IVW_GRAM_1 differ diff --git a/libraries/mogo-speech/src/main/assets/ivw/IVW_KEYWORD_1 b/libraries/mogo-speech/src/main/assets/ivw/IVW_KEYWORD_1 new file mode 100644 index 0000000000..12a58d4e56 Binary files /dev/null and b/libraries/mogo-speech/src/main/assets/ivw/IVW_KEYWORD_1 differ diff --git a/libraries/mogo-speech/src/main/assets/ivw/IVW_MLP_1 b/libraries/mogo-speech/src/main/assets/ivw/IVW_MLP_1 new file mode 100644 index 0000000000..e6ab1b577a Binary files /dev/null and b/libraries/mogo-speech/src/main/assets/ivw/IVW_MLP_1 differ diff --git a/libraries/mogo-speech/src/main/assets/ivw/version_2 b/libraries/mogo-speech/src/main/assets/ivw/version_2 new file mode 100644 index 0000000000..c227083464 --- /dev/null +++ b/libraries/mogo-speech/src/main/assets/ivw/version_2 @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/libraries/mogo-speech/src/main/java/com/mogo/mgintelligent/speech/iflytek/WakeManager.kt b/libraries/mogo-speech/src/main/java/com/mogo/mgintelligent/speech/iflytek/WakeManager.kt new file mode 100644 index 0000000000..6c6c65d10e --- /dev/null +++ b/libraries/mogo-speech/src/main/java/com/mogo/mgintelligent/speech/iflytek/WakeManager.kt @@ -0,0 +1,103 @@ +package com.mogo.mgintelligent.speech.iflytek + +import android.content.Context +import android.util.Log +import com.iflytek.aikit.core.AiHelper +import com.iflytek.aikit.core.BaseLibrary +import com.iflytek.aikit.core.CoreListener +import com.iflytek.aikit.core.ErrType +import com.iflytek.aikit.core.LogLvl +import com.mogo.commons.AbsMogoApplication +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +import com.mogo.eagle.core.utilcode.util.FileUtils +import com.mogo.eagle.core.utilcode.util.ResourceUtils +import com.mogo.eagle.core.utilcode.util.ThreadUtils +import com.mogo.eagle.core.utilcode.util.Utils +import java.io.File + +object WakeManager { + + private val TAG = "WakeManager" + + private val coreListener = CoreListener { type, code -> + Log.i(TAG, "core listener code:$code") + + when (type) { + ErrType.AUTH -> { + if (code == 0) { + Log.i(TAG, "SDK授权成功") + } else { + Log.i(TAG, "SDK授权失败,授权码为:$code") + } + + } + + ErrType.HTTP -> Log.i(TAG, "SDK状态:HTTP认证结果$code") + + else -> Log.i(TAG, "SDK状态:其他错误$code") + } + + } + + fun initWakeAi(context: Context) { + + try { + val workDir = getWorkDir() + copyFile(workDir) + val file = File(workDir) + if(!file.exists()){ + file.mkdirs() + } + AiHelper.getInst().setLogInfo(LogLvl.VERBOSE, 1, "${workDir}aeeLog.txt") + + //设定初始化参数 + val params = BaseLibrary.Params.builder() + .appId("0c498b42") //您的应用ID,可从控制台查看 + .apiKey("8579f566eb7f3c4f4a07148ad9e2408c") //您的APIKEY,可从控制台查看 + .apiSecret("NTRmMmI5MWI4NzIzZTIxN2Q5N2FjMWVl") //您的APISECRET,可从控制台查看 + .workDir(workDir) //SDK的工作目录,需要确保有读写权限。一般用于存放离线能力资源,日志存放目录等使用。 + .build() + + AiHelper.getInst().registerListener(coreListener) // 注册SDK 初始化状态监听 + AiHelper.getInst().initEntry(context, params) + }catch (e:Exception){ + CallerLogger.d(TAG,"初始化失败:${e.message}") + } + } + + private fun copyFile(workDir: String) { + ThreadUtils.getIoPool().submit{ + val dir = "ivw" + val targetDir = workDir + File.separator + dir + if(checkCopied(dir,targetDir)) { + FileUtils.deleteAllInDir(targetDir) + ResourceUtils.copyFileFromAssets(dir, targetDir) + CallerLogger.d(TAG,"copy 完成") + }else{ + CallerLogger.d(TAG,"文件已经存在 不需要copy") + } + + } + } + + private fun checkCopied(dir: String, targetDir: String): Boolean { + val assets = Utils.getApp().assets.list(dir)?.toMutableList() + val tartgetFile = File(targetDir) + if(tartgetFile.isDirectory){ + tartgetFile.listFiles { dir, name -> + (assets?.contains(name)?:true).apply { + assets?.remove(name) + } + } + return assets?.isNotEmpty()?:false + } + return true + } + + fun getWorkDir():String{ + AbsMogoApplication.getApp()?.let { + return it.filesDir.path + File.separator + "iflytek" + File.separator + } + throw IllegalArgumentException("找不到 Application") + } +} \ No newline at end of file