CosyVoice V3 Plus API 接口、参数 & 代码示例

tongyi/cosyvoice-v3-plus

CosyVoice V3 Plus 是通义实验室推出的最新一代生成式语音合成(TTS)大模型。该模型代表了目前 CosyVoice 系列中合成效果最佳、综合能力最强的旗舰版本。

模型 ID
tongyi/cosyvoice-v3-plus
模型系列
TongYi
更新日期
模型能力
语音合成
模型价格(每千字符)
¥ 0.25
默认音色
longanyang

CosyVoice V3 Plus 模型介绍:

CosyVoice V3 Plus 是通义实验室推出的最新一代生成式语音合成(TTS)大模型。该模型代表了目前 CosyVoice 系列中合成效果最佳、综合能力最强的旗舰版本。

核心功能与亮点

  • 零样本声音复刻(Zero-Shot Voice Cloning): 仅需提供 10~20秒 的发音人样本音频,即可在不进行任何额外训练的情况下,快速生成高度相似、自然且极具表现力的定制音色。
  • 声音设计(Voice Design): 支持通过纯文本描述(如描述性别、年龄、音色特征、多语言等维度)来无中生有地创造出全新的、符合特定人设的虚拟音色。
  • 方言与多语言支持: 相比前代,v3-plus 大幅增强了多语言及中国各地方言的复刻与操控能力。

语言与方言支持能力

功能分类 支持的语种 / 方言
声音复刻 中文方言(普通话、广东话、东北话、甘肃话、贵州话、河南话、湖北话、江西话、闽南话、宁夏话、山西话、陕西话、山东话、上海话、四川话、天津话、云南话)

外语(英文、法语、德语、日语、韩语、俄语)
声音设计 中文(普通话)、英文

音频输出规格

CosyVoice V3 Plus 提供了极高的音频兼容性,能够满足从电话客服到超高清广播等各种场景的需求:

  • 输出格式: pcmwavmp3opus
  • 采样率(Sample Rate): 支持广泛的采样率调节,包括 8kHz16kHz22.05kHz24kHz44.1kHz48kHz

适用场景与方案选择

CosyVoice V3 Plus 主要服务于以下场景:

  1. 标准语音合成: 当内置的官方音色库(包含多语种、各年龄段、客服/小说等丰富人设)已经能满足需求时,可直接调用进行高品质文本转语音。
  2. 个性化复刻/设计: 用于需要打造品牌专属声音、复刻特定人物、或为游戏/动漫角色创建全新音色。

💡 CosyVoice V3 Plus 目前仅支持 longanyang(龙安洋,阳光大男孩) 和 longanhuan(龙安欢,欢脱元气女) 2 个系统音色 ID。

API 接口地址:

https://wcode.net/api/gpt/v1/audio/speech

此 API 接口兼容 OpenAI 的 Text-to-Speech 接口规范,可直接使用 OpenAI 的 SDK 来调用。仅需替换以下配置即可:

  1. base_url 替换为 https://wcode.net/api/gpt/v1
  2. api_key 替换为从 https://platform.wcode.net 获取到的 API Key

具体可参考下方的各编程语言代码示例中的 OpenAI SDK 调用示例。

请求方法:

POST

各编程语言代码示例:

# TODO: 以下代码中的 API_KEY 需要替换,获取 API Key 入口:https://platform.wcode.net
# 响应为音频二进制,可使用 --output speech.mp3 保存文件
curl --request POST 'https://wcode.net/api/gpt/v1/audio/speech' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer API_KEY' \
--output speech.mp3 \
--data '{
    "model": "tongyi/cosyvoice-v3-plus",
    "input": "你好,今天天气怎么样。",
    "voice": "longanyang"
}'
import Foundation

let headers = [
  "Authorization": "Bearer API_KEY",  // TODO: 这里的 API_KEY 需要替换,获取 API Key 入口:https://platform.wcode.net
  "content-type": "application/json"
]
let parameters = [
  "model": "tongyi/cosyvoice-v3-plus",
  "input": "你好,今天天气怎么样。",
  "voice": "longanyang"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://wcode.net/api/gpt/v1/audio/speech")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 60.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else if let data = data {
    try? data.write(to: URL(fileURLWithPath: "speech.mp3"))
  }
})

dataTask.resume()
import 'dart:convert';
import 'dart:io';
import 'package:http/http.dart' as http;

Future<void> main() async {
  var headers = {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer API_KEY'  // TODO: 这里的 API_KEY 需要替换,获取 API Key 入口:https://platform.wcode.net
  };
  var request = http.Request('POST', Uri.parse('https://wcode.net/api/gpt/v1/audio/speech'));
  request.body = json.encode({
    "model": "tongyi/cosyvoice-v3-plus",
    "input": "你好,今天天气怎么样。",
    "voice": "longanyang"
  });
  request.headers.addAll(headers);

  http.StreamedResponse response = await request.send();

  if (response.statusCode == 200) {
    var bytes = await response.stream.toBytes();
    File('speech.mp3').writeAsBytesSync(bytes);
  }
  else {
    print(response.reasonPhrase);
  }
}
require 'uri'
require 'net/http'

url = URI("https://wcode.net/api/gpt/v1/audio/speech")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer API_KEY'  # TODO: 这里的 API_KEY 需要替换,获取 API Key 入口:https://platform.wcode.net
request["content-type"] = 'application/json'
request.body = "{\"model\":\"tongyi/cosyvoice-v3-plus\",\"input\":\"你好,今天天气怎么样。\",\"voice\":\"longanyang\"}"

response = http.request(request)
File.write("speech.mp3", response.body) if response.is_a?(Net::HTTPSuccess)
use serde_json::json;
use reqwest;
use std::fs;

#[tokio::main]
pub async fn main() {
  let url = "https://wcode.net/api/gpt/v1/audio/speech";

  let payload = json!({
    "model": "tongyi/cosyvoice-v3-plus",
    "input": "你好,今天天气怎么样。",
    "voice": "longanyang"
  });

  let mut headers = reqwest::header::HeaderMap::new();
  headers.insert("Authorization", "Bearer API_KEY".parse().unwrap());  // TODO: 这里的 API_KEY 需要替换,获取 API Key 入口:https://platform.wcode.net
  headers.insert("content-type", "application/json".parse().unwrap());

  let client = reqwest::Client::new();
  let response = client.post(url)
    .headers(headers)
    .json(&payload)
    .send()
    .await
    .unwrap();

  let audio_bytes = response.bytes().await.unwrap();
  fs::write("speech.mp3", audio_bytes).unwrap();
}
#include <stdio.h>
#include <curl/curl.h>

static size_t write_callback(void *contents, size_t size, size_t nmemb, void *userp) {
  return fwrite(contents, size, nmemb, (FILE *)userp);
}

CURL *hnd = curl_easy_init();

curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "https://wcode.net/api/gpt/v1/audio/speech");

struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Authorization: Bearer API_KEY");  // TODO: 这里的 API_KEY 需要替换,获取 API Key 入口:https://platform.wcode.net
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);

curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\"model\":\"tongyi/cosyvoice-v3-plus\",\"input\":\"你好,今天天气怎么样。\",\"voice\":\"longanyang\"}");

FILE *fp = fopen("speech.mp3", "wb");
curl_easy_setopt(hnd, CURLOPT_WRITEFUNCTION, write_callback);
curl_easy_setopt(hnd, CURLOPT_WRITEDATA, fp);

CURLcode ret = curl_easy_perform(hnd);

fclose(fp);
curl_easy_cleanup(hnd);
curl_slist_free_all(headers);
package main

import (
  "fmt"
  "os"
  "strings"
  "net/http"
  "io"
)

func main() {
  url := "https://wcode.net/api/gpt/v1/audio/speech"

  payload := strings.NewReader("{\"model\":\"tongyi/cosyvoice-v3-plus\",\"input\":\"你好,今天天气怎么样。\",\"voice\":\"longanyang\"}")

  req, _ := http.NewRequest("POST", url, payload)

  req.Header.Add("Authorization", "Bearer API_KEY")  // TODO: 这里的 API_KEY 需要替换,获取 API Key 入口:https://platform.wcode.net
  req.Header.Add("content-type", "application/json")

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := io.ReadAll(res.Body)

  os.WriteFile("speech.mp3", body, 0644)
  fmt.Println(res.Status)
}
using System.Net.Http.Headers;


var client = new HttpClient();

var request = new HttpRequestMessage(HttpMethod.Post, "https://wcode.net/api/gpt/v1/audio/speech");

request.Headers.Add("Authorization", "Bearer API_KEY");  // TODO: 这里的 API_KEY 需要替换,获取 API Key 入口:https://platform.wcode.net

request.Content = new StringContent("{\"model\":\"tongyi/cosyvoice-v3-plus\",\"input\":\"你好,今天天气怎么样。\",\"voice\":\"longanyang\"}", null, "application/json");

var response = await client.SendAsync(request);

response.EnsureSuccessStatusCode();

await File.WriteAllBytesAsync("speech.mp3", await response.Content.ReadAsByteArrayAsync());
var client = new RestClient("https://wcode.net/api/gpt/v1/audio/speech");

var request = new RestRequest("", Method.Post);

request.AddHeader("Authorization", "Bearer API_KEY");  // TODO: 这里的 API_KEY 需要替换,获取 API Key 入口:https://platform.wcode.net

request.AddHeader("content-type", "application/json");

request.AddParameter("application/json", "{\"model\":\"tongyi/cosyvoice-v3-plus\",\"input\":\"你好,今天天气怎么样。\",\"voice\":\"longanyang\"}", ParameterType.RequestBody);

var response = client.Execute(request);

if (response.IsSuccessful && response.RawBytes != null)
    await File.WriteAllBytesAsync("speech.mp3", response.RawBytes);
const axios = require('axios');
const fs = require('fs');

let data = JSON.stringify({
  "model": "tongyi/cosyvoice-v3-plus",
  "input": "你好,今天天气怎么样。",
  "voice": "longanyang"
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://wcode.net/api/gpt/v1/audio/speech',
  responseType: 'arraybuffer',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer API_KEY'  // TODO: 这里的 API_KEY 需要替换,获取 API Key 入口:https://platform.wcode.net
  },
  data : data
};

axios.request(config).then((response) => {
  fs.writeFileSync('speech.mp3', response.data);
}).catch((error) => {
  console.log(error);
});
import java.nio.file.Files;
import java.nio.file.Path;

OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");

RequestBody body = RequestBody.create(mediaType, "{\"model\":\"tongyi/cosyvoice-v3-plus\",\"input\":\"你好,今天天气怎么样。\",\"voice\":\"longanyang\"}");

Request request = new Request.Builder()
  .url("https://wcode.net/api/gpt/v1/audio/speech")
  .post(body)
  .addHeader("Authorization", "Bearer API_KEY")  // TODO: 这里的 API_KEY 需要替换,获取 API Key 入口:https://platform.wcode.net
  .addHeader("content-type", "application/json")
  .build();

try (Response response = client.newCall(request).execute()) {
  if (response.isSuccessful() && response.body() != null) {
    Files.write(Path.of("speech.mp3"), response.body().bytes());
  }
}
$client = new \GuzzleHttp\Client();

$headers = [
  'Content-Type' => 'application/json',
  'Authorization' => 'Bearer API_KEY',  // TODO: 这里的 API_KEY 需要替换,获取 API Key 入口:https://platform.wcode.net
];

$body = '{
  "model": "tongyi/cosyvoice-v3-plus",
  "input": "你好,今天天气怎么样。",
  "voice": "longanyang"
}';

$request = new \GuzzleHttp\Psr7\Request('POST', 'https://wcode.net/api/gpt/v1/audio/speech', $headers, $body);

$response = $client->sendAsync($request)->wait();

file_put_contents('speech.mp3', $response->getBody()->getContents());
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://wcode.net/api/gpt/v1/audio/speech",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 5,
  CURLOPT_TIMEOUT => 300,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode([
    'model' => 'tongyi/cosyvoice-v3-plus',
    'input' => '你好,今天天气怎么样。',
    'voice' => 'longanyang',
  ]),
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer API_KEY",  // TODO: 这里的 API_KEY 需要替换,获取 API Key 入口:https://platform.wcode.net
    "content-type: application/json",
  ],
]);

$response = curl_exec($curl);
$error = curl_error($curl);

curl_close($curl);

if ($error) {
  echo "cURL Error #:" . $error;
} else {
  file_put_contents('speech.mp3', $response);
}
import requests

url = "https://wcode.net/api/gpt/v1/audio/speech"

payload = {
  "model": "tongyi/cosyvoice-v3-plus",
  "input": "你好,今天天气怎么样。",
  "voice": "longanyang"
}

headers = {
  "Authorization": "Bearer API_KEY",  # TODO: 这里的 API_KEY 需要替换,获取 API Key 入口:https://platform.wcode.net
  "content-type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

with open("speech.mp3", "wb") as f:
  f.write(response.content)
from openai import OpenAI

client = OpenAI(
  base_url="https://wcode.net/api/gpt/v1",
  api_key="API_KEY"  # TODO: 这里的 API_KEY 需要替换,获取 API Key 入口:https://platform.wcode.net
)

response = client.audio.speech.create(
  model="tongyi/cosyvoice-v3-plus",
  input="你好,今天天气怎么样。",
  voice="longanyang",
)

response.write_to_file("speech.mp3")

请求参数:

重要提示:由于模型架构不同,部分参数可能仅适用于特定的模型。

model(模型 ID)

  • 参数:model

  • 必选,string

语音合成模型 ID。调用时使用模型详情页的模型 ID。

input(输入文本)

  • 参数:input

  • 必选,string

需要进行语音合成的文本内容。

bit_rate(比特率)

  • 参数:bit_rate

  • 可选,integer,6 到 510

  • 默认:32

指定 Opus 编码的比特率(kbps)。

仅当 response_formatopus 时生效。

sample_rate(采样率)

  • 参数:sample_rate

  • 可选,integer

  • 取值范围:8000 | 16000 | 22050 | 24000 | 44100 | 48000

  • 默认:22050

指定返回音频的采样率(Hz)。

enable_ssml(启用 SSML)

  • 参数:enable_ssml

  • 可选,boolean

  • 默认:false

是否将输入文本按 SSML 语法解析。

voice(音色)

  • 参数:voice

  • 可选,string

  • 默认:longanyang

语音合成所使用的音色 ID。

CosyVoice 音色列表:https://help.aliyun.com/zh/model-studio/cosyvoice-voice-list

stream(流式响应)

  • 参数:stream

  • 可选,boolean

  • 取值范围:true | false

  • 默认:false

是否以流式方式返回音频数据。

当前接口暂不支持流式响应;请勿设置 stream: true,否则将返回错误。

seed(随机种子)

  • 参数:seed

  • 可选,integer,0 到 65535

  • 默认:0

控制合成结果的随机性;相同 seed 与参数组合可复现相同音频。

volume(音量)

  • 参数:volume

  • 可选,integer,0 到 100

  • 默认:50

控制合成语音的音量大小。

pitch(音调)

  • 参数:pitch

  • 可选,float,0.5 到 2.0

  • 默认:1.0

控制合成语音的音调。

speed(语速)

  • 参数:speed

  • 可选,float,0.5 到 2.0

  • 默认:1.0

控制合成语音的语速。

response_format(音频格式)

  • 参数:response_format

  • 可选,string

  • 取值范围:mp3 | pcm | wav | opus

  • 默认:mp3

指定返回音频的编码格式。


以上文档为标准版 API 接口文档,可直接用于项目开发和系统调用。如果标准版 API 接口无法满足您的需求,需要定制开发 API 接口,请联系我们的 IT 技术支持工程师:

(沟通需求✅ → 确认技术方案✅ → 沟通费用与工期✅ → 开发&测试✅ → 验收交付✅ → 维护升级✅)

最受关注模型

DeepSeek V4 Pro

文本生成、深度思考

DeepSeek V4 Flash

文本生成、深度思考

Qwen 3.6 Plus

文本生成、深度思考、视觉理解

XiaoMi MiMo V2.5 Pro

文本生成、深度思考

Kimi K2.6

文本生成、深度思考、工具调用

最新发布模型

CosyVoice V3 Plus

语音合成

DeepSeek V4 Flash

文本生成、深度思考

DeepSeek V4 Pro

文本生成、深度思考

CosyVoice V3 Flash

语音合成

Qwen3 ASR Flash

语音识别

向量化模型

GLM Embedding 3

文本向量化

Qwen3 Embedding 8B

文本嵌入、文本向量化

Doubao Embedding Large Text 250515

文本向量化

Qwen Text Embedding V4

文本向量化

Qwen Text Embedding V1

文本向量化

语音识别模型

Fun ASR Flash

语音识别、方言识别

Qwen3 ASR Flash

语音识别

GLM ASR 2512

语音识别

语音合成模型

CosyVoice V3 Plus

语音合成

CosyVoice V3 Flash

语音合成

GLM TTS

语音合成