文本转语音
使用当前引擎、克隆配置或设计的声音生成语音。
POST /v1/audio/speech 接收 OpenAI 语音请求格式并返回音频字节。tts-1 和 tts-1-hd 使用 VoiceStudio 中选定的引擎;omnivoice、voxcpm2、cosyvoice 或 kittentts 等引擎 ID 指定对应引擎。
curl "$VOICESTUDIO_BASE_URL/audio/speech" \
-H "Authorization: Bearer $VOICESTUDIO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "tts-1",
"voice": "default",
"input": "Every voice. Every language. On your machine.",
"response_format": "wav",
"speed": 1.0
}' \
--output speech.wav字段
| 字段 | 含义 |
|---|---|
input | 要朗读的文本,最多 4,096 个字符 |
model | tts-1、tts-1-hd 或引擎 ID |
voice | default、OpenAI 别名、引擎预设或配置 ID |
response_format | mp3、opus、aac、flac、wav 或原始 pcm |
speed | 0.25 至 4.0 |
引擎控制
请求还接受引擎专属字段:
{
"model": "omnivoice",
"input": "Say this softly, then pause.",
"voice": "your-profile-id",
"language": "en",
"instruct": "quiet, intimate, unhurried",
"seed": 42,
"num_step": 32,
"guidance_scale": 2.0
}支持情况因引擎而异。GET /v1/audio/voices 列出已安装引擎及其克隆、情绪、设备和路由能力。
响应为二进制
将其写入文件或流式传输;不要作为 JSON 解析。检查 Content-Type:如果编码器不可用,服务器可能回退到 WAV。
长文本
单次请求最多接受 4,096 个字符。书籍、播客或可恢复任务请使用 API 参考中的有声书和长篇路由。