内容更新日: 2026-06-06
テキスト音声合成 (TTS)
POST /v1/audio/speech
リクエストパラメータ
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
model | string | はい | モデル名:tts-1、tts-1、tts-1-hd-1106 |
input | string | はい | 変換するテキスト。最大 4096 文字 |
voice | string | はい | 音声の役割 |
response_format | string | いいえ | 出力形式:mp3(デフォルト)、opus、aac、flac、wav、pcm |
speed | number | いいえ | 話速、0.25-4.0、デフォルト 1.0 |
利用可能な音声
| 音声 | 特徴 |
|---|---|
alloy | 中性・バランス |
echo | 男性・落ち着き |
fable | 男性・温かみ |
onyx | 男性・深み |
nova | 女性・元気 |
shimmer | 女性・柔らかさ |
リクエスト例
curl -X POST https://api.crazyrouter.com/v1/audio/speech \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "tts-1",
"input": "你好,欢迎使用 Crazyrouter API。今天天气真不错!",
"voice": "nova",
"response_format": "mp3",
"speed": 1.0
}' \
--output speech.mp3
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.crazyrouter.com/v1"
)
response = client.audio.speech.create(
model="tts-1",
input="你好,欢迎使用 Crazyrouter API。今天天气真不错!",
voice="nova",
response_format="mp3",
speed=1.0
)
response.stream_to_file("speech.mp3")
import OpenAI from "openai";
import fs from "fs";
const client = new OpenAI({
apiKey: "YOUR_API_KEY",
baseURL: "https://api.crazyrouter.com/v1",
});
const response = await client.audio.speech.create({
model: "tts-1",
input: "你好,欢迎使用 Crazyrouter API。",
voice: "nova",
});
const buffer = Buffer.from(await response.arrayBuffer());
fs.writeFileSync("speech.mp3", buffer);
モデル比較
| モデル | 品質 | レイテンシ | 説明 |
|---|---|---|---|
tts-1 | 標準 | 低 | リアルタイム用途に適しています |
tts-1-hd-1106 | 高精細 | 中 | より自然な音声 |
tts-1 | 最高 | 中 | 最新モデル。より多くの言語と感情をサポート |
tts-1 は多言語をサポートしており、入力テキストの言語を自動認識し、適切な発音を使用します。レスポンスはバイナリ音声ストリームであり、JSON ではありません。
--output またはストリーム書き込みでファイル保存してください。