APIリファレンス
オーディオ
音声生成、音声文字起こし、音声翻訳の API を使用します。
オーディオ API には、音声生成、文字起こし、翻訳が含まれます。音声生成では JSON リクエストボディを使用し、文字起こしと翻訳では通常、音声ファイルをアップロードするためにマルチパートフォームデータを使用します。
エンドポイント
| メソッド | パス | 説明 |
|---|---|---|
POST | /v1/audio/speech | テキストから音声への変換 |
POST | /v1/audio/transcriptions | 音声の文字起こし |
POST | /v1/audio/translations | 音声の翻訳 |
リクエストフィールド
| フィールド | 型 | 適用対象 | 説明 |
|---|---|---|---|
model | string | All | 音声モデル ID(必須) |
input | string | speech | 音声合成するテキスト |
voice | string | speech | 音声(ボイス) ID |
instructions | string | speech | 音声のスタイルまたは追加指示 |
response_format | string | All | レスポンス形式。文字起こしと翻訳のデフォルトは json |
speed | number | speech | 音声の速度 |
stream_format | string | speech | モデルがサポートしている場合、sse に設定するとストリーミングが有効になります |
metadata | object | speech | パススルーされるメタデータ |
file | file | transcriptions/translations | マルチパートフォームデータで送信する音声ファイル(必須) |
language | any | extension | 一部のチャネルでサポートされる言語オプション |
音声生成
curl https://api.tensoraxis.com/v1/audio/speech \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TENSORAXIS_API_KEY" \
-d '{
"model": "tts-1",
"voice": "alloy",
"input": "Hello from TENSORAXIS.",
"response_format": "mp3"
}' \
--output speech.mp3文字起こし
curl https://api.tensoraxis.com/v1/audio/transcriptions \
-H "Authorization: Bearer $TENSORAXIS_API_KEY" \
-F model="whisper-1" \
-F file="@audio.mp3" \
-F response_format="json"翻訳
curl https://api.tensoraxis.com/v1/audio/translations \
-H "Authorization: Bearer $TENSORAXIS_API_KEY" \
-F model="whisper-1" \
-F file="@audio.mp3" \
-F response_format="json"レスポンスの形式
JSON 形式の文字起こしと翻訳のレスポンスには通常 text が含まれます:
{
"text": "Transcribed text..."
}音声生成はバイナリ音声データを直接返します。レスポンスの Content-Type は response_format とアップストリームのモデルによって異なります。