メインコンテンツへスキップ
ARouter は3つのモードで包括的な音声サポートを提供します:音声テキスト変換(文字起こしと翻訳)、テキスト音声変換(TTS)、音声チャット(音声入力を受け付け、音声出力を生成するマルチモーダルモデル)。

音声文字起こし

OpenAI 互換の /v1/audio/transcriptions エンドポイントを使用して音声ファイルをテキストに文字起こしします。
curl https://api.arouter.ai/v1/audio/transcriptions \
  -H "Authorization: Bearer lr_live_xxxx" \
  -F file="@audio.mp3" \
  -F model="openai/whisper-large-v3"
from openai import OpenAI
client = OpenAI(base_url="https://api.arouter.ai/v1", api_key="lr_live_xxxx")
with open("audio.mp3", "rb") as audio_file:
    transcription = client.audio.transcriptions.create(
        model="openai/whisper-large-v3", file=audio_file, response_format="text"
    )
print(transcription.text)

文字起こしパラメータ

パラメータ説明
filefile文字起こしする音声ファイル。対応フォーマット:flacmp3mp4mpegmpgam4aoggwavwebm
modelstringモデル ID(例:openai/whisper-large-v3
languagestringBCP-47 言語コード(例:"en""ja")。指定すると精度が向上します。
promptstring文字起こしスタイルを誘導したり語彙ヒントを提供する任意のテキスト
response_formatstring出力形式:json(デフォルト)、textsrtverbose_jsonvtt
temperaturenumberサンプリング温度 0–1。値が高いほどランダム性が増します。
timestamp_granularitiesstring[]タイムスタンプ付き出力の粒度:["word"] または ["segment"]verbose_json が必要)

単語レベルのタイムスタンプ

transcription = client.audio.transcriptions.create(
    model="openai/whisper-large-v3", file=audio_file,
    response_format="verbose_json", timestamp_granularities=["word"]
)
for word in transcription.words:
    print(f"{word.start:.2f}s - {word.end:.2f}s: {word.word}")

音声翻訳

任意の言語の音声を英語テキストに翻訳します:
with open("foreign_audio.mp3", "rb") as audio_file:
    translation = client.audio.translations.create(
        model="openai/whisper-large-v3", file=audio_file, response_format="text"
    )
print(translation.text)

テキスト音声変換

テキストを自然な音声に変換します:
response = client.audio.speech.create(
    model="openai/tts-1-hd", voice="nova",
    input="Hello! Welcome to ARouter, the universal AI gateway."
)
response.stream_to_file("output.mp3")

TTS パラメータ

パラメータ説明
modelstringTTS モデル(例:openai/tts-1 または openai/tts-1-hd
inputstring合成するテキスト。最大 4,096 文字。
voicestring使用する音声:alloyechofableonyxnovashimmer
response_formatstring音声フォーマット:mp3(デフォルト)、opusaacflacwavpcm
speednumber再生速度 0.25 から 4.0(デフォルト 1.0

使用可能な音声

音声特徴
alloyニュートラル、バランス
echo柔らか、内省的
fable表現豊か、物語調
onyx低音、権威ある
novaフレンドリー、エネルギッシュ
shimmer温かみ、穏やか

音声チャット(マルチモーダルモデル)

一部のモデルはチャットメッセージの入力として音声を直接受け付け、音声オーディオで応答できます。

音声入力

{
  "model": "openai/gpt-5.4-audio-preview",
  "messages": [{
    "role": "user",
    "content": [{"type": "input_audio", "input_audio": {"data": "<base64-encoded-audio>", "format": "wav"}}]
  }]
}

対応入力音声フォーマット

フォーマットMIME タイプ
wavaudio/wav
mp3audio/mpeg
oggaudio/ogg
flacaudio/flac
m4aaudio/m4a
webmaudio/webm

音声出力

モデルのレスポンスに音声オーディオをリクエストします:
{
  "model": "openai/gpt-5.4-audio-preview",
  "modalities": ["text", "audio"],
  "audio": {"voice": "nova", "format": "mp3"},
  "messages": [{"role": "user", "content": "Tell me a short joke."}]
}

対応モデル

音声テキスト変換

モデル言語備考
openai/whisper-large-v399以上最高精度
openai/whisper-large-v3-turbo99以上より高速、低コスト

テキスト音声変換

モデル品質レイテンシ
openai/tts-1標準
openai/tts-1-hd

Token 料金

音声 Token は usage.prompt_tokens_details で個別に追跡されます:
{
  "usage": {
    "prompt_tokens": 150,
    "prompt_tokens_details": {"audio_tokens": 100, "cached_tokens": 0},
    "completion_tokens": 50,
    "completion_tokens_details": {"audio_tokens": 30}
  }
}
音声 Token はテキスト Token とは異なる料金が適用されます。各リクエストの実際の料金はレスポンスの usage.cost を確認してください。