cURL
model 是克隆模型(固定为 qwen-voice-enrollment)。target_model 是用于合成克隆音色的语音合成模型。后续合成调用中的 model 必须与此处的 target_model 一致,否则会导致调用失败。您须确保对提供的音频拥有合法所有权和使用权。使用本 API 前,请阅读服务条款。
上传音频创建克隆音色。无需训练,即时返回音色名称。
curl -X POST https://dashscope.aliyuncs.com/api/v1/services/audio/tts/customization \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen-voice-enrollment",
"input": {
"action": "create",
"target_model": "qwen3-tts-vc-realtime-2026-01-15",
"preferred_name": "guanyu",
"audio": {
"data": "https://xxx.wav"
}
}
}'{
"output": {
"voice": "qwen-tts-vc-guanyu-voice-20250812105009984-838b",
"target_model": "qwen3-tts-vc-realtime-2026-01-15"
},
"usage": {
"count": 1
},
"request_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}model 是克隆模型(固定为 qwen-voice-enrollment)。target_model 是用于合成克隆音色的语音合成模型。后续合成调用中的 model 必须与此处的 target_model 一致,否则会导致调用失败。显示Base64 编码示例
import base64, pathlib
# 将 input.mp3 替换为您的音频文件路径
file_path = pathlib.Path("input.mp3")
base64_str = base64.b64encode(file_path.read_bytes()).decode()
data_uri = f"data:audio/mpeg;base64,{base64_str}"
import java.nio.file.*;
import java.util.Base64;
public class Main {
public static String toDataUrl(String filePath) throws Exception {
byte[] bytes = Files.readAllBytes(Paths.get(filePath));
String encoded = Base64.getEncoder().encodeToString(bytes);
return "data:audio/mpeg;base64," + encoded;
}
public static void main(String[] args) throws Exception {
System.out.println(toDataUrl("input.mp3"));
}
}
千问云 API Key。详见获取 API Key。
声音克隆模型。固定为 qwen-voice-enrollment。
显示子属性
操作类型。固定为 create。
克隆声音对应的语音合成模型。必须与后续合成调用中使用的模型一致。可选值:qwen3-tts-vc-realtime-2026-01-15、qwen3-tts-vc-realtime-2025-11-27(实时)、qwen3-tts-vc-2026-01-22(非实时)。
声音名称中的关键词(支持数字、字母、下划线,最多 16 个字符)。会出现在生成的声音名称中。示例:guanyu 对应生成 qwen-tts-vc-guanyu-voice-20250812105009984-838b。
显示子属性
用于克隆的音频。支持两种格式:Data URL -- data:<mediatype>;base64,<data>(<mediatype> 为 audio/wav、audio/mpeg 或 audio/mp4;Base64 编码后的数据需小于 10 MB)。音频 URL -- 可公开访问的 URL(无需鉴权)。
与音频内容对应的文本。服务器会验证匹配程度,若差异过大则返回 Audio.PreprocessError。
音频语言。指定后必须与音频实际语言一致。
curl -X POST https://dashscope.aliyuncs.com/api/v1/services/audio/tts/customization \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen-voice-enrollment",
"input": {
"action": "create",
"target_model": "qwen3-tts-vc-realtime-2026-01-15",
"preferred_name": "guanyu",
"audio": {
"data": "https://xxx.wav"
}
}
}'{
"output": {
"voice": "qwen-tts-vc-guanyu-voice-20250812105009984-838b",
"target_model": "qwen3-tts-vc-realtime-2026-01-15"
},
"usage": {
"count": 1
},
"request_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}