生产级 VoxCPM TTS 服务,支持 GPU 加速、OpenAI 兼容 API、自定义音色、流式输出
# 直接播放语音(无需安装)
curl -s https://voxcpm-tts.aws.xin/v1/audio/speech \
-H "Content-Type: application/json" \
-d '{"model": "tts-1", "input": "你好,欢迎使用语音合成", "voice": "alloy", "response_format": "wav"}' \
| ffplay -autoexit -nodisp -
# 保存为文件
curl -s https://voxcpm-tts.aws.xin/v1/audio/speech \
-H "Content-Type: application/json" \
-d '{"model": "tts-1", "input": "你好世界", "voice": "alloy", "response_format": "wav"}' \
-o hello.wav
docker pull neosun/voxcpm-allinone:latest
docker run -d \
--name voxcpm \
--gpus all \
-p 7861:7861 \
-v ./voices:/app/voices \
-v ./outputs:/app/outputs \
--restart unless-stopped \
neosun/voxcpm-allinone:latest
version: '3.8'
services:
voxcpm:
image: neosun/voxcpm-allinone:latest
container_name: voxcpm
runtime: nvidia
environment:
- NVIDIA_VISIBLE_DEVICES=all
ports:
- "7861:7861"
volumes:
- ./voices:/app/voices
- ./outputs:/app/outputs
restart: unless-stopped
docker-compose up -d
# WAV 格式
curl -s http://localhost:7861/v1/audio/speech \
-H "Content-Type: application/json" \
-d '{"model": "tts-1", "input": "让子弹飞一会儿", "voice": "alloy", "response_format": "wav"}' \
-o speech.wav
# MP3 格式
curl -s http://localhost:7861/v1/audio/speech \
-H "Content-Type: application/json" \
-d '{"model": "tts-1", "input": "让子弹飞一会儿", "voice": "alloy", "response_format": "mp3"}' \
-o speech.mp3
# PCM 流式(最低延迟)
curl -s http://localhost:7861/v1/audio/speech \
-H "Content-Type: application/json" \
-d '{"model": "tts-1", "input": "让子弹飞一会儿", "voice": "alloy", "response_format": "pcm"}' \
| ffplay -f s16le -ar 44100 -ac 1 -autoexit -nodisp -
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 否 | tts-1(快速), tts-1-hd(高质量), gpt-4o-mini-tts |
input | string | 是 | 要合成的文本(最大4096字符) |
voice | string | 否 | 预设音色或自定义 voice_id |
response_format | string | 否 | wav, mp3, pcm, opus, aac, flac |
speed | float | 否 | 语速 0.25-4.0,默认 1.0 |
alloy, echo, fable, onyx, nova, shimmer, ash, ballad, coral, sage, verse
curl -X POST http://localhost:7861/v1/voices/create \
-F "audio=@your_voice.wav" \
-F "name=我的音色" \
-F "text=音频对应的文本内容"
响应:
{
"success": true,
"voice_id": "20cfdc63ddf8",
"name": "我的音色",
"message": "音色创建成功,使用 voice='20cfdc63ddf8' 调用 /v1/audio/speech"
}
curl -s http://localhost:7861/v1/audio/speech \
-H "Content-Type: application/json" \
-d '{"model": "tts-1", "input": "让子弹飞一会儿", "voice": "20cfdc63ddf8", "response_format": "wav"}' \
-o output.wav
# 列出所有自定义音色
curl -s http://localhost:7861/v1/voices/custom | jq .
# 获取音色详情
curl -s http://localhost:7861/v1/voices/20cfdc63ddf8 | jq .
# 删除音色
curl -X DELETE http://localhost:7861/v1/voices/20cfdc63ddf8
# WAV 流式播放
curl -s http://localhost:7861/v1/audio/speech \
-H "Content-Type: application/json" \
-d '{"model": "tts-1", "input": "你好世界", "voice": "alloy", "response_format": "wav"}' \
| ffplay -autoexit -nodisp -
# 使用 aplay(Linux)
curl -s http://localhost:7861/v1/audio/speech \
-H "Content-Type: application/json" \
-d '{"model": "tts-1", "input": "你好", "voice": "alloy", "response_format": "wav"}' \
| aplay
使用 Web Audio API 实现 PCM 流式播放,边生成边播放,无需等待完整音频。
| 端点 | 方法 | 说明 |
|---|---|---|
/v1/audio/speech | POST | 语音合成(支持流式) |
/v1/voices/create | POST | 上传音频创建自定义音色 |
/v1/voices/custom | GET | 列出所有自定义音色 |
/v1/voices/{voice_id} | GET | 获取音色详情 |
/v1/voices/{voice_id} | DELETE | 删除自定义音色 |
/v1/models | GET | 列出可用模型 |
/v1/voices | GET | 列出预设音色 |
/health | GET | 健康检查 |
/docs | GET | Swagger API 文档 |
| 指标 | 数值 |
|---|---|
| PCM 首字节延迟 | ~0.001s |
| WAV 首字节延迟 | ~0.09s |
| 生成速度 | 2-8s(取决于文本长度) |
| 音频质量 | 44.1kHz, 16-bit PCM |
| GPU 显存占用 | ~2.1GB |
| 服务 | 地址 |
|---|---|
| API 服务 | https://voxcpm-tts.aws.xin |
| API 文档 | https://voxcpm-tts.aws.xin/docs |
/v1/audio/speech 端点Apache License 2.0
Made with ❤️ by the VoxCPM Community
Python
88.8%
HTML
10.0%
生产级 VoxCPM TTS 服务,支持 GPU 加速、OpenAI 兼容 API、自定义音色、流式输出
# 直接播放语音(无需安装)
curl -s https://voxcpm-tts.aws.xin/v1/audio/speech \
-H "Content-Type: application/json" \
-d '{"model": "tts-1", "input": "你好,欢迎使用语音合成", "voice": "alloy", "response_format": "wav"}' \
| ffplay -autoexit -nodisp -
# 保存为文件
curl -s https://voxcpm-tts.aws.xin/v1/audio/speech \
-H "Content-Type: application/json" \
-d '{"model": "tts-1", "input": "你好世界", "voice": "alloy", "response_format": "wav"}' \
-o hello.wav
docker pull neosun/voxcpm-allinone:latest
docker run -d \
--name voxcpm \
--gpus all \
-p 7861:7861 \
-v ./voices:/app/voices \
-v ./outputs:/app/outputs \
--restart unless-stopped \
neosun/voxcpm-allinone:latest
version: '3.8'
services:
voxcpm:
image: neosun/voxcpm-allinone:latest
container_name: voxcpm
runtime: nvidia
environment:
- NVIDIA_VISIBLE_DEVICES=all
ports:
- "7861:7861"
volumes:
- ./voices:/app/voices
- ./outputs:/app/outputs
restart: unless-stopped
docker-compose up -d
# WAV 格式
curl -s http://localhost:7861/v1/audio/speech \
-H "Content-Type: application/json" \
-d '{"model": "tts-1", "input": "让子弹飞一会儿", "voice": "alloy", "response_format": "wav"}' \
-o speech.wav
# MP3 格式
curl -s http://localhost:7861/v1/audio/speech \
-H "Content-Type: application/json" \
-d '{"model": "tts-1", "input": "让子弹飞一会儿", "voice": "alloy", "response_format": "mp3"}' \
-o speech.mp3
# PCM 流式(最低延迟)
curl -s http://localhost:7861/v1/audio/speech \
-H "Content-Type: application/json" \
-d '{"model": "tts-1", "input": "让子弹飞一会儿", "voice": "alloy", "response_format": "pcm"}' \
| ffplay -f s16le -ar 44100 -ac 1 -autoexit -nodisp -
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 否 | tts-1(快速), tts-1-hd(高质量), gpt-4o-mini-tts |
input | string | 是 | 要合成的文本(最大4096字符) |
voice | string | 否 | 预设音色或自定义 voice_id |
response_format | string | 否 | wav, mp3, pcm, opus, aac, flac |
speed | float | 否 | 语速 0.25-4.0,默认 1.0 |
alloy, echo, fable, onyx, nova, shimmer, ash, ballad, coral, sage, verse
curl -X POST http://localhost:7861/v1/voices/create \
-F "audio=@your_voice.wav" \
-F "name=我的音色" \
-F "text=音频对应的文本内容"
响应:
{
"success": true,
"voice_id": "20cfdc63ddf8",
"name": "我的音色",
"message": "音色创建成功,使用 voice='20cfdc63ddf8' 调用 /v1/audio/speech"
}
curl -s http://localhost:7861/v1/audio/speech \
-H "Content-Type: application/json" \
-d '{"model": "tts-1", "input": "让子弹飞一会儿", "voice": "20cfdc63ddf8", "response_format": "wav"}' \
-o output.wav
# 列出所有自定义音色
curl -s http://localhost:7861/v1/voices/custom | jq .
# 获取音色详情
curl -s http://localhost:7861/v1/voices/20cfdc63ddf8 | jq .
# 删除音色
curl -X DELETE http://localhost:7861/v1/voices/20cfdc63ddf8
# WAV 流式播放
curl -s http://localhost:7861/v1/audio/speech \
-H "Content-Type: application/json" \
-d '{"model": "tts-1", "input": "你好世界", "voice": "alloy", "response_format": "wav"}' \
| ffplay -autoexit -nodisp -
# 使用 aplay(Linux)
curl -s http://localhost:7861/v1/audio/speech \
-H "Content-Type: application/json" \
-d '{"model": "tts-1", "input": "你好", "voice": "alloy", "response_format": "wav"}' \
| aplay
使用 Web Audio API 实现 PCM 流式播放,边生成边播放,无需等待完整音频。
| 端点 | 方法 | 说明 |
|---|---|---|
/v1/audio/speech | POST | 语音合成(支持流式) |
/v1/voices/create | POST | 上传音频创建自定义音色 |
/v1/voices/custom | GET | 列出所有自定义音色 |
/v1/voices/{voice_id} | GET | 获取音色详情 |
/v1/voices/{voice_id} | DELETE | 删除自定义音色 |
/v1/models | GET | 列出可用模型 |
/v1/voices | GET | 列出预设音色 |
/health | GET | 健康检查 |
/docs | GET | Swagger API 文档 |
| 指标 | 数值 |
|---|---|
| PCM 首字节延迟 | ~0.001s |
| WAV 首字节延迟 | ~0.09s |
| 生成速度 | 2-8s(取决于文本长度) |
| 音频质量 | 44.1kHz, 16-bit PCM |
| GPU 显存占用 | ~2.1GB |
| 服务 | 地址 |
|---|---|
| API 服务 | https://voxcpm-tts.aws.xin |
| API 文档 | https://voxcpm-tts.aws.xin/docs |
/v1/audio/speech 端点Apache License 2.0
Made with ❤️ by the VoxCPM Community
Python
88.8%
HTML
10.0%