diff --git a/README.md b/README.md index e138e21..177cc0b 100644 --- a/README.md +++ b/README.md @@ -95,8 +95,8 @@ dashScopeApiKey: '' imageModel: 'qwen-image-2.0' # 是否在生成图片右下角添加 Qwen-Image 水印 imageWatermark: false -# 百炼平台TTS模型 -ttsModel: 'qwen-tts' +# 百炼平台TTS模型,qwen3-tts-instruct-flash 支持 instructions 指令控制语气 +ttsModel: 'qwen3-tts-instruct-flash' # Jina API Key jinaApiKey: '' # SearXNG 搜索引擎地址,如 http://127.0.0.1:8080/search 必须启用允许json格式返回 diff --git a/src/main/kotlin/PluginConfig.kt b/src/main/kotlin/PluginConfig.kt index 3430793..c78580b 100644 --- a/src/main/kotlin/PluginConfig.kt +++ b/src/main/kotlin/PluginConfig.kt @@ -56,8 +56,8 @@ object PluginConfig : AutoSavePluginConfig("Config") { @ValueDescription("是否在生成的图片右下角添加 Qwen-Image 水印") val imageWatermark: Boolean by value(false) - @ValueDescription("百炼平台TTS模型") - val ttsModel: String by value("qwen-tts") + @ValueDescription("百炼平台TTS模型。qwen3-tts-instruct-flash 支持 instructions 指令控制;纯发音可用 qwen3-tts-flash 或 qwen-tts") + val ttsModel: String by value("qwen3-tts-instruct-flash") @ValueDescription("Jina API Key") val jinaApiKey by value("") diff --git a/src/main/kotlin/tools/SendVoiceMessage.kt b/src/main/kotlin/tools/SendVoiceMessage.kt index b60bdcc..30aacc7 100644 --- a/src/main/kotlin/tools/SendVoiceMessage.kt +++ b/src/main/kotlin/tools/SendVoiceMessage.kt @@ -21,7 +21,7 @@ import kotlin.time.measureTime class SendVoiceMessage : BaseAgent( tool = Tool.function( name = "sendVoiceMessage", - description = "发送一条文本转语音消息。", + description = "发送一条文本转语音消息。可选传入 instructions 用自然语言指令控制语气、语速、情感等表达方式,让语音更贴合当前对话氛围。", parameters = Parameters.buildJsonObject { put("type", "object") putJsonObject("properties") { @@ -29,6 +29,10 @@ class SendVoiceMessage : BaseAgent( put("type", "string") put("description", "语音消息文本内容") } + putJsonObject("instructions") { + put("type", "string") + put("description", "可选。自然语言描述本句话的表达方式,例如\"语速较快,带有明显的上扬语调\"或\"温柔知性,语调平和\"。仅支持中英文。") + } } putJsonArray("required") { add("content") @@ -52,6 +56,7 @@ class SendVoiceMessage : BaseAgent( if (event.subject !is AudioSupported) return "当前聊天环境不支持发送语音!" val content = args.getValue("content").jsonPrimitive.content + val instructions = args["instructions"]?.jsonPrimitive?.content?.takeIf { it.isNotBlank() } // https://help.aliyun.com/zh/model-studio/qwen-tts val response = httpClient.post(API_URL) { @@ -62,6 +67,10 @@ class SendVoiceMessage : BaseAgent( putJsonObject("input") { put("text", content) put("voice", "Chelsie") // Chelsie(女) Cherry(女) Ethan(男) Serena(女) + if (instructions != null) { + put("instructions", instructions) + put("optimize_instructions", true) + } } }.toString()) }