[tts 回调日志]
This commit is contained in:
yangyakun
2024-08-13 20:12:00 +08:00
parent a419361def
commit d2937350ac
2 changed files with 16 additions and 1 deletions

View File

@@ -46,6 +46,9 @@ object OchChainLogManager {
// 局域网内socket 连接状态流转
const val EVENT_KEY_INFO_AUTOPILOT = "analytics_event_och_autopilot"
const val EVENT_KEY_INFO_VOICE_TTS = "analytics_event_och_voice_tts"
fun writeChainLogNet(mustUpdate: Boolean, title: String, info: String) {
if(mustUpdate){

View File

@@ -5,6 +5,7 @@ import com.mogo.commons.voice.AIAssist
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
import com.mogo.och.common.module.manager.audiofocus.AudioFocusManager
import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager
import com.mogo.tts.base.IMogoTTSCallback
import com.mogo.tts.base.LangTtsEntity
import com.mogo.tts.base.LanguageType
@@ -38,6 +39,7 @@ object VoiceNotice {
@JvmStatic
fun showNotice(notice: String?, level: Int, delayed: Long = 0,callBack:IMogoTTSCallback?=null) {
save2Log("准备播放 内容${notice}__level:${level}__delayed:${delayed}")
notice?.let {
if (delayed == 0L) {
UiThreadHandler.post {
@@ -58,6 +60,7 @@ object VoiceNotice {
*/
@JvmStatic
fun stopCurrentTts(){
save2Log("停止播放")
UiThreadHandler.post {
AIAssist.getInstance(AbsMogoApplication.getApp()).stopTts()
}
@@ -74,13 +77,15 @@ object VoiceNotice {
}
listTTS.removeAll(tempList)
}
save2Log("准备播放${listTTS}")
AIAssist.getInstance(AbsMogoApplication.getApp())
.speakMultiLangTTSWithLevel(MultiLangTtsEntity(listTTS), level,callCallBack(callBack))
}
fun speakTTSVoiceWithLevel(text:String, level:Int, callBack:IMogoTTSCallback){
AIAssist.getInstance(AbsMogoApplication.getApp()).speakTTSVoiceWithLevel(text,level,callBack)
save2Log("准备播放${text}")
AIAssist.getInstance(AbsMogoApplication.getApp()).speakTTSVoiceWithLevel(text,level,callCallBack(callBack))
}
@@ -92,19 +97,26 @@ object VoiceNotice {
super.onSpeakStart(speakText)
callBack?.onSpeakStart(speakText)
AudioFocusManager.setTTSFocusChange(true)
save2Log("开始播放${speakText}")
}
override fun onSpeakEnd(speakText: String?) {
super.onSpeakEnd(speakText)
callBack?.onSpeakEnd(speakText)
AudioFocusManager.setTTSFocusChange(false)
save2Log("结束播放${speakText}")
}
override fun onSpeakError(speakText: String?, errorMsg: String?) {
super.onSpeakError(speakText, errorMsg)
callBack?.onSpeakError(speakText,errorMsg)
AudioFocusManager.setTTSFocusChange(false)
save2Log("播放错误,内容:${speakText}、errorMsg:${errorMsg}")
}
}
}
fun save2Log(info: String){
OchChainLogManager.writeChainLog("tts",info,true, eventID = OchChainLogManager.EVENT_KEY_INFO_VOICE_TTS)
}
}