|
|
@ -774,6 +774,9 @@ object AgentService : CoroutineScope { |
|
|
// 通知ChatAPI服务终止当前流式请求 |
|
|
// 通知ChatAPI服务终止当前流式请求 |
|
|
chatApiService.cancelCurrentStream() |
|
|
chatApiService.cancelCurrentStream() |
|
|
|
|
|
|
|
|
|
|
|
//结束等待音 |
|
|
|
|
|
audioPlayer?.stopAudio() |
|
|
|
|
|
|
|
|
} catch (e: Exception) { |
|
|
} catch (e: Exception) { |
|
|
Log.e(TAG, "停止AI流输出异常", e) |
|
|
Log.e(TAG, "停止AI流输出异常", e) |
|
|
// 确保状态被重置,即使发生异常 |
|
|
// 确保状态被重置,即使发生异常 |
|
|
@ -973,8 +976,6 @@ object AgentService : CoroutineScope { |
|
|
responseBuilder.append(token) |
|
|
responseBuilder.append(token) |
|
|
if (speakResponse && reply && broadcast && token.isNotEmpty()) { |
|
|
if (speakResponse && reply && broadcast && token.isNotEmpty()) { |
|
|
ttsService?.speakStream(token) |
|
|
ttsService?.speakStream(token) |
|
|
// 在开始流式TTS时立即停止气泡音 |
|
|
|
|
|
// audioPlayer?.stopAudio() |
|
|
|
|
|
} |
|
|
} |
|
|
if (reply && token.isNotEmpty()) { |
|
|
if (reply && token.isNotEmpty()) { |
|
|
// 发送流式回复token |
|
|
// 发送流式回复token |
|
|
@ -1591,7 +1592,7 @@ object AgentService : CoroutineScope { |
|
|
// 新增:超时相关属性 |
|
|
// 新增:超时相关属性 |
|
|
private var timeoutHandler: Handler? = null |
|
|
private var timeoutHandler: Handler? = null |
|
|
private var timeoutRunnable: Runnable? = null |
|
|
private var timeoutRunnable: Runnable? = null |
|
|
private var timeoutSeconds: Long = 10000L // 默认10秒超时 |
|
|
private var timeoutSeconds: Long = 30000L // 默认10秒超时 |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 安全检查 MediaPlayer 是否正在播放 |
|
|
* 安全检查 MediaPlayer 是否正在播放 |
|
|
|