diff --git a/local_plugins/azure_speech/android/src/main/kotlin/com/yunqiinnovation/azure_speech/AzureTtsHelper.kt b/local_plugins/azure_speech/android/src/main/kotlin/com/yunqiinnovation/azure_speech/AzureTtsHelper.kt index 70227503f..b08fb0d50 100644 --- a/local_plugins/azure_speech/android/src/main/kotlin/com/yunqiinnovation/azure_speech/AzureTtsHelper.kt +++ b/local_plugins/azure_speech/android/src/main/kotlin/com/yunqiinnovation/azure_speech/AzureTtsHelper.kt @@ -243,7 +243,15 @@ class AzureTtsHelper(private val context: Context) : ITtsService { )) } } - + //清洗播报语音内容 + fun cleanTextForTTS(text: String): String { + return text + .replace(Regex("https?://\\S+"), "") // 移除 URL + .replace(Regex("[\\p{Punct}]"), "") // 可选:移除标点符号(你可能不想全部移除) + .replace(Regex("[\uD83C-\uDBFF\uDC00-\uDFFF]+"), "") // 移除 emoji 表情 + .replace(Regex("\\s+"), " ") // 多个空格合并 + .trim() + } /** * 设置语音参数 */ @@ -372,8 +380,7 @@ class AzureTtsHelper(private val context: Context) : ITtsService { } lastSpeakTime = currentTime - val currentText = streamBuffer.toString() - + val currentText = cleanTextForTTS(streamBuffer.toString()) // 定义标点符号列表 val punctuationMarks = listOf('.', '。', '!', '!', '?', '?', ';', ';', ',', ',', ':', ':', '\n') diff --git a/local_plugins/open_ai_service/android/src/main/kotlin/com/yunqiinnovation/open_ai_service/OpenAIService.kt b/local_plugins/open_ai_service/android/src/main/kotlin/com/yunqiinnovation/open_ai_service/OpenAIService.kt index d5464724e..b04b9a0ab 100644 --- a/local_plugins/open_ai_service/android/src/main/kotlin/com/yunqiinnovation/open_ai_service/OpenAIService.kt +++ b/local_plugins/open_ai_service/android/src/main/kotlin/com/yunqiinnovation/open_ai_service/OpenAIService.kt @@ -679,7 +679,7 @@ class OpenAIService(private val context: Context? = null) : CoroutineScope { } } } - Log.d(TAG, "liwei---------------------- AI发起工具调用: tool=$toolCallsArray") + Log.i(TAG, "liwei---------------------- AI发起工具调用: tool=$toolCallsArray") } } @@ -706,7 +706,7 @@ class OpenAIService(private val context: Context? = null) : CoroutineScope { put("arguments", firstToolCall.arguments) put("id", firstToolCall.id) } - Log.d(TAG, "liwei---------------------- 工具调用: id=${firstToolCall.id}, name=${firstToolCall.name} arguments=${firstToolCall.arguments}") + Log.i(TAG, "liwei---------------------- 工具调用: id=${firstToolCall.id}, name=${firstToolCall.name} arguments=${firstToolCall.arguments}") // 通知上层工具调用事件 callback.onFunctionCall(functionCall) @@ -734,7 +734,7 @@ class OpenAIService(private val context: Context? = null) : CoroutineScope { val context = resultObj.optString("context", "工具调用失败").let { if (it.isNullOrEmpty()) "工具调用失败" else it } - Log.d(TAG, "liwei----------------------- mcp工具调用完成: name=${firstToolCall.name}, context=$context") + Log.i(TAG, "liwei----------------------- mcp工具调用完成: name=${firstToolCall.name}, context=$context") // 将结果发送回OpenAI继续对话 sendFunctionCallResult( diff --git a/local_plugins/open_ai_service/android/src/main/kotlin/com/yunqiinnovation/open_ai_service/SystemFunctionHandler.kt b/local_plugins/open_ai_service/android/src/main/kotlin/com/yunqiinnovation/open_ai_service/SystemFunctionHandler.kt index d56f3d77d..931e29810 100644 --- a/local_plugins/open_ai_service/android/src/main/kotlin/com/yunqiinnovation/open_ai_service/SystemFunctionHandler.kt +++ b/local_plugins/open_ai_service/android/src/main/kotlin/com/yunqiinnovation/open_ai_service/SystemFunctionHandler.kt @@ -332,8 +332,8 @@ class SystemFunctionHandler(private val context: Context) { */ private fun registerMediaPlayFunction(client: MCPClient) { client.registerLocalFunction( - "media_play", - "播放媒体", + "media_resume", + "继续媒体播放", JSONObject(""" { "type": "object",