目次
音声合成(TTS)ガイド
音声合成(TTS)ガイド
POST /v1/audio/speech は OpenAI-compatible です。JSON を送ると音声ファイルのバイナリが返ります。ElevenLabs 系列には elevenlabs/eleven-v4、eleven-v4-turbo、eleven-v3、eleven-v3-conversational、eleven-multilingual-v2、eleven-flash-v2.5、eleven-flash-v2、eleven-turbo-v2.5、eleven-turbo-v2 があります。最新一覧は GET /v1/models?output_modalities=speech を参照してください。 GET /v1/models は既定ではテキストモデルのみを返すため、?output_modalities=speech(または all)を付けて一覧を取得してください。
/v1/audio/speechパラメーター
| パラメーター | 型 | 必須 | 説明 |
|---|---|---|---|
| model | string | はい | 音声モデル ID。例: elevenlabs/eleven-flash-v2.5。 |
| input | string | はい | 合成するテキスト。1 リクエストあたり最大 4,096 文字(elevenlabs/eleven-v4 と eleven-v4-turbo は 10,000 文字)。それより長い場合は複数のリクエストに分けてください。 |
| voice | string | はい | 使用する声。形式はモデルにより異なります。以下の声の規則を参照してください。 |
| response_format | string | いいえ | mp3(既定)または pcm。opus・aac・flac・wav は API では受け付けますが、現在 ElevenLabs モデルでは 400 で拒否されます。 |
| speed | number | いいえ | 話速は 0.25~4.0。モデルによっては適用されません。 |
| instructions | string | いいえ | 声のスタイル指定。モデルによっては適用されません。 |
| stability | number | いいえ | 声の安定性(0〜1、既定 0.5)。低いほど感情豊か、高いほど平坦になります。当社の直接音声ルートで処理される elevenlabs/* モデルで有効です。レスポンスヘッダー X-Voice-Settings が applied(適用)か ignored(未適用)を示します。 |
| similarity_boost | number | いいえ | 元の声との類似度(0〜1、既定 0.75)。Eleven v3 では使われません。 |
| style | number | いいえ | スタイルの強調度(0〜1、既定 0)。0 より大きいと遅延が増えます。Eleven v4 では使われません。 |
| use_speaker_boost | boolean | いいえ | 元の話者との類似度を高めます(既定 true)。わずかに遅延が増えます。 |
| clone_strength | number | いいえ | クローン強度(0〜1、通常は 0 を推奨)。Eleven v4 向けに学習したご自身のプロフェッショナルクローン音声(voice_…)にのみ有効です。 |
| language_code | string | いいえ | 読み上げ言語を指定する 2 文字の小文字の言語コード(ISO 639-1。例:ar、ja、en)。multilingual-v2 モデルでは使われません。 |
| audio_effects | object | いいえ | 任意のオーディオエフェクトのオブジェクト:filter_preset_id(フィルター。例 phone、old_radio)、environment_id(残響空間。例 small_room、hall)、background_noise_id(背景音。例 cafe)、distance(距離 0〜1)、send_level(残響量 0〜1)、pan(左右位置 −1〜1)。ID は小文字・数字・アンダースコアのみ。追加料金はありません。残響または pan が 0 以外だとステレオ出力になり、pcm 出力とは併用できません。 |
上の 7 つの音声設定はすべて任意で、指定しなければ何も変わりません。範囲外の値は 400 を返し、送信も課金もされません。レスポンスヘッダー X-Voice-Settings は設定が使われたかを示します:applied=適用、ignored=予備ルートが応答したため設定は使われませんでした(音声は通常どおり生成されます)、ヘッダーなし=音声設定を送っていません。例:stability を 0 にすると抑揚が大きく、1 にするとより均一に読み上げます。
声の規則
ElevenLabs モデル(elevenlabs/…)には次の音声名(大文字小文字不問)を指定できます: george, sarah, adam, alice, bella, bill, brian, callum, charlie, chris, daniel, eric, harry, jessica, laura, liam, lily, matilda, river, roger, will。ElevenLabs モデルでは voice を省略できます(既定は george)。それ以外の値は 400 invalid_voice になります。自分のカスタムボイス(voice_…)は下の「カスタムボイス」セクションを参照してください。
alloy、echo、nova などの OpenAI-style の声名は、それらを列挙するモデルでのみ使えます。モデルページを確認してください。
カスタムボイス(クローン)は段階的に公開中です。下の「カスタムボイス」セクション(POST /v1/voices)をご覧ください。アカウントで有効になるまでは、上の 21 個のプリセット名か公開ボイス ID をお使いください。
組み込み音声一覧
voice には下表の音声名(小文字)を指定できます。各音声に短い試聴クリップがあり、GET /api/v1/audio/voices で全一覧(性別・年齢層・アクセント・スタイル・試聴 URL)を取得できます。
?lang=(en、zh-TW、zh-CN。既定は Accept-Language)は description の言語だけを決めます。試聴 URL は変わりません:preview_urls.en(preview_url と同じ)が英語、preview_urls.zh(preview_url_zh と同じ)が中国語のクリップです。
| 音声 | 説明 | 試聴 |
|---|---|---|
| george | Male, middle-aged, British accent. Mature and steady, suited to narration and storytelling. | |
| sarah | Female, young adult, American accent. Professional and clear, suited to broadcast-style reading. | |
| adam | Male, middle-aged, American accent. Everyday and approachable, suited to short social videos. | |
| alice | Female, middle-aged, British accent. Professional and informative, suited to explainers and teaching. | |
| bella | Female, middle-aged, American accent. Professional and informative, suited to explainers and teaching. | |
| bill | Male, senior, American accent. Crisp and direct, suited to advertising voice-overs. | |
| brian | Male, middle-aged, American accent. Polished and refined, suited to social and brand content. | |
| callum | Male, middle-aged, American accent. Expressive, suited to characters and animation. | |
| charlie | Male, young adult, Australian accent. Energetic and lively, suited to conversation. | |
| chris | Male, middle-aged, American accent. Relaxed and casual, suited to conversation. | |
| daniel | Male, middle-aged, British accent. Formal and measured, suited to news-style and educational reading. | |
| eric | Male, middle-aged, American accent. Polished and warm, suited to conversation. | |
| harry | Male, young adult, American accent. Rough and gritty, suited to character voices. | |
| jessica | Female, young adult, American accent. Bright and cute, suited to conversation. | |
| laura | Female, young adult, American accent. Playful with attitude, suited to social content. | |
| liam | Male, young adult, American accent. Confident and upbeat, suited to social content. | |
| lily | Female, middle-aged, British accent. Confident and clear, suited to explainers and teaching. | |
| matilda | Female, middle-aged, American accent. Upbeat and friendly, suited to explainers and teaching. | |
| river | Neutral voice, middle-aged, American accent. Calm and even, suited to conversation. | |
| roger | Male, middle-aged, American accent. Polished and confident, suited to conversation. | |
| will | Male, young adult, American accent. Laid-back and easygoing, suited to conversation. |
感情・動作タグ(audio tags)
input の中に角括弧でタグを直接書きます。例: [laughs]、[whispers]、[excited]、[sighs]、[crying]、[curious]、[softly]。タグは入力どおりモデルに渡され、続く言葉の演じ方を決めます。本文が日本語でもタグは英語のままにしてください。
curl https://api.bazaarlink.ai/v1/audio/speech \
-H "Authorization: Bearer $BAZAARLINK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"elevenlabs/eleven-v3","input":"[laughs] That was actually funny. [whispers] Do not tell anyone.","voice":"george","response_format":"mp3"}' \
--output audio-tags.mp3elevenlabs/eleven-v3 と elevenlabs/eleven-v4 系列が対応しています。ほかの音声モデルはタグを解釈せず、括弧の中を読み上げることがあるため、まず短い文で試してください。
タグも input の文字数に含まれ、ほかのテキストと同じように課金されます。
出力形式
response_format を省略すると mp3(Content-Type は audio/mpeg)になります。pcm(audio/pcm、生の 16-bit PCM)も使えます。API は opus、aac、flac、wav も受け付けますが、ElevenLabs モデルは現在 400 で拒否します。保存時はレスポンスの Content-Type ヘッダーに従ってください。
料金
音声合成は入力文字数で課金されます。文字単価は /models のモデルページと GET /v1/models の pricing.character にあります。モデルページでは 100 万文字単位で表示されます。
例
curl https://api.bazaarlink.ai/v1/audio/speech \
-H "Authorization: Bearer $BAZAARLINK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"elevenlabs/eleven-flash-v2.5","input":"Hello from BazaarLink.","voice":"george","response_format":"mp3"}' \
--output speech.mp3よくあるエラー
| 状態 | 原因と対処 |
|---|---|
| 400 | 不正なリクエスト: model、input、voice の欠落、input が 4,096 文字超、speed が 0.25~4.0 の範囲外、未対応の response_format、Unknown voice、unknown_model(/models で ID を確認)。 |
| 401 | API キーがないか無効です。Authorization: Bearer で BazaarLink キーを送ってください。 |
| 402 | 残高不足です。チャージして再試行してください。 |
| 403 | 管理キーはモデルを呼び出せないか、アカウントが停止中です。通常の API キーを使ってください。 |
| 429 | レート制限です。Retry-After ヘッダーに従って再試行してください。 |
| 502 | モデルサービスが一時的に利用できないか音声転送が中断されました。再試行してください。失敗したリクエストは課金されません。 |
音声合成
/v1/models?output_modalities=speech のモデル ID でテキストを音声に変換します。モデルページの100万文字あたりの価格で課金されます。音声全体をバッファしてからバイナリで返し、分割ストリーミングには対応していません。provider、transforms、route、service_tier、preset などのルーティング制御フィールドは無視されます。
/v1/audio/speech/v1/chat/completions/v1/chat/completions に audio または input_audio を渡し、音声対応モデルを選びます。報告された文字と音声のトークン合計に、設定された入力・出力単価を一律適用します。
curl https://api.bazaarlink.ai/v1/chat/completions \
-H "$BAZAARLINK_AUTH_HEADER" \
-H "Content-Type: application/json" \
-d '{"model":"<audio-chat-model-id>","messages":[{"role":"user","content":"Say hi."}],"stream":true,"modalities":["text","audio"],"audio":{"voice":"alloy","format":"pcm16"},"max_tokens":32}'