Upgrade TTS to qwen3-tts-instruct-flash with instruction control

Adds an optional instructions parameter to sendVoiceMessage so the model
can describe tone, pace and emotion in natural language. Defaults the
TTS model to qwen3-tts-instruct-flash; Chelsie voice is unchanged.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-22 15:57:15 +08:00
parent 39b49bb302
commit 92acbb2310
3 changed files with 14 additions and 5 deletions

View File

@@ -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格式返回

View File

@@ -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("")

View File

@@ -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())
}