Browse Source

上传协议代码

newdev_shunjiawei
liwei1dao 10 months ago
parent
commit
5839bc68e0
  1. 10
      local_plugins/agent_service/android/src/main/kotlin/com/yunqiinnovation/agent_service/AgentService.kt
  2. 8
      local_plugins/agent_service/ios/agent_service/Sources/agent_service/AgentServiceImpl.swift

10
local_plugins/agent_service/android/src/main/kotlin/com/yunqiinnovation/agent_service/AgentService.kt

@ -383,7 +383,7 @@ object AgentService : CoroutineScope {
restartIdleCheck()
sendEvent("tts_started", mapOf("status" to "started"))
// 停止气泡音,避免与TTS同时播放
// audioPlayer?.stopAudio()
}
TtsEventType.SYNTHESIS_COMPLETED -> {
@ -404,7 +404,7 @@ object AgentService : CoroutineScope {
restartIdleCheck()
sendEvent("playback_started", mapOf("status" to "playback_started"))
// 确保气泡音已停止,避免与TTS播放重叠
// audioPlayer?.stopAudio()
audioPlayer?.stopAudio()
if(_isInterrupt.get()){
BleService.closeCodec()
}
@ -1119,7 +1119,7 @@ object AgentService : CoroutineScope {
if (reply && token.isNotEmpty()) {
// 发送流式回复token
sendEvent("assistant_token", mapOf("sessionid" to sessionid,"token" to token))
audioPlayer?.stopAudio()
// audioPlayer?.stopAudio()
}
} catch (e: Exception) {
Log.e(TAG, "liwei--------------- AI Call onToken 异常", e)
@ -1231,9 +1231,7 @@ object AgentService : CoroutineScope {
try {
Log.d(
TAG,
"liwei--------------- AI Call onFunctionCallResult ${sessionid}:${functionCallResult.toString()}",
)
"liwei--------------- AI Call onFunctionCallResult ${sessionid}:${functionCallResult.toString()}",)
audioPlayer?.stopAudio()
val name = functionCall.get("name") as String;
val resultmap = autoHandleFcunCallResult(name, functionCallResult);

8
local_plugins/agent_service/ios/agent_service/Sources/agent_service/AgentServiceImpl.swift

@ -1701,9 +1701,9 @@ class ChatApiStreamCallback: StreamCallback {
return
}
if (token != "" && responseBuilder.isEmpty) { //关闭声音
try agentService.audioPlayer?.stopAwaitSound()
}
// if (token != "" && responseBuilder.isEmpty) { //关闭声音
// try agentService.audioPlayer?.stopAwaitSound()
// }
responseBuilder += token
if speakResponse && reply && broadcast{
@ -1892,7 +1892,6 @@ extension AgentServiceImpl: TtsEventListener {
isSpeaking = true
restartIdleCheck()
sendEvent(name: "tts_started", data: ["status": "started"])
// audioPlayer?.stopAwaitSound()
case .synthesisCompleted:
isSpeaking = false
@ -1902,6 +1901,7 @@ extension AgentServiceImpl: TtsEventListener {
case .playbackStarted:
restartIdleCheck()
sendEvent(name: "playback_started", data: ["status": "playback_started"])
audioPlayer?.stopAwaitSound()
MusicService.shared.reduceVolume()
if(isInterrupt){ //播报开始。打断唤醒输入
BleService.shared.closeCodec()

Loading…
Cancel
Save