Skip to content

Speech (Text-to-Speech) ​

將文本轉換為音訊,採用通用 Speech 協議格式。

POST https://router.accels.tech/v1/audio/speech

請求體 ​

引數型別必填說明
modelstring✓如 tts-1、tts-1-hd、gpt-4o-mini-tts、cosyvoice-v1
inputstring✓待合成文本,<= 4096 字元
voicestring✓如 alloy、echo、fable、onyx、nova、shimmer,或廠商專屬 voice
response_formatstringmp3(預設)、opus、aac、flac、wav、pcm
speednumber語速,0.25 ~ 4.0,預設 1.0
instructionsstring音色 / 風格引導(如 gpt-4o-mini-tts)
stream_formatstring流式格式,如 sse / audio

響應 ​

直接返回音訊二進位制流,Content-Type 為 audio/mpeg 等。

示例 ​

bash
curl https://router.accels.tech/v1/audio/speech \
  -H "Authorization: Bearer $ACCELSROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "tts-1",
    "input": "你好,我是 AccelsRouter 的語音助手。",
    "voice": "nova"
  }' --output hello.mp3
python
from pathlib import Path
from openai import OpenAI
client = OpenAI(api_key="sk-...", base_url="https://router.accels.tech/v1")

resp = client.audio.speech.create(
    model="tts-1-hd",
    voice="alloy",
    input="歡迎使用 AccelsRouter 文字轉語音。",
)
Path("welcome.mp3").write_bytes(resp.content)