PieBox
文档中心

文字转语音 (TTS)

Gemini TTS 和 ElevenLabs TTS 语音合成

Gemini TTS(多语种)

英文效果最佳,支持 24 种常用语言。返回原始 PCM 音频数据。

请求:

POST /v2/extend/tts/gemini/synthesize

参数:

参数类型必填说明
textstring要合成的文本(≤ 10000 字符)
voice_namestring音色名称(如 Kore、Puck、Charon 等)
promptstring语音风格提示(如 "speak slowly and clearly")
language_codestring语言代码(如 en-US、zh-CN)
temperaturenumber控制随机性

示例:

curl https://tokenhub.piegateway.me/v2/extend/tts/gemini/synthesize \
  -H "X-API-Key: <your-api-key>" \
  -H "Content-Type: application/json" \
  -d '{"text": "Hello, this is a test.", "voice_name": "Kore"}' \
  -o output.pcm

返回:二进制 PCM 音频流(LINEAR16, 24kHz, 单声道)。

用 ffmpeg 转换为可播放格式:

ffmpeg -f s16le -ar 24000 -ac 1 -i output.pcm output.mp3

ElevenLabs TTS(高音质)

业界顶级音质,支持 70+ 种语言。

请求:

POST /v2/extend/tts/elevenlabs/synthesize

参数:

参数类型必填说明
textstring要合成的文本(≤ 10000 字符)
voice_idstring音色 ID
language_codestring语言代码
output_formatstring输出格式

示例:

curl https://tokenhub.piegateway.me/v2/extend/tts/elevenlabs/synthesize \
  -H "X-API-Key: <your-api-key>" \
  -H "Content-Type: application/json" \
  -d '{"text": "Hello world", "voice_id": "21m00Tcm4TlvDq8ikWAM"}' \
  -o output.mp3