メインコンテンツへスキップ

リクエストボディ

同期リクエストのタイムアウト: この非チャットエンドポイントは、ルーティング先モデルの処理完了を待ちます。大きな入力、長い音声、大きなバッチは一般的な 30s のクライアント既定値を超えることがあるため、HTTP クライアントのタイムアウトは少なくとも 120s に設定してください。
file
file
必須
文字起こしする音声ファイル。対応形式: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, webm。
model
string
デフォルト:"whisper-1"
使用するモデル。現在は whisper-1 のみサポートされています。
language
string
ISO-639-1 形式の音声言語(例: en, zh, ja)。
prompt
string
モデルのスタイルを誘導したり、前のセグメントの続きを生成したりするための任意のテキスト。
response_format
string
デフォルト:"json"
出力形式: json, text, srt, verbose_json, vtt
temperature
number
デフォルト:"0"
サンプリング温度(0 から 1)。
timestamp_granularities
array
タイムスタンプの粒度: word および/または segmentverbose_json が必要です。

レスポンス

text
string
文字起こしされたテキスト。
verbose_json の場合:
task
string
常に transcribe
language
string
検出された言語。
duration
number
音声の長さ(秒)。
segments
array
タイムスタンプ付きの文字起こしセグメント。
words
array
単語レベルのタイムスタンプ(要求された場合)。
curl -X POST "https://api.tokenlab.sh/v1/audio/transcriptions" \
  -H "Authorization: Bearer sk-your-api-key" \
  -F file="@audio.mp3" \
  -F model="whisper-1" \
  -F language="en"
from openai import OpenAI

client = OpenAI(
    api_key="sk-your-api-key",
    base_url="https://api.tokenlab.sh/v1"
)

with open("audio.mp3", "rb") as audio_file:
    response = client.audio.transcriptions.create(
        model="whisper-1",
        file=audio_file,
        language="en"
    )

print(response.text)
import OpenAI from 'openai';
import fs from 'fs';

const client = new OpenAI({
  apiKey: 'sk-your-api-key',
  baseURL: 'https://api.tokenlab.sh/v1'
});

const response = await client.audio.transcriptions.create({
  model: 'whisper-1',
  file: fs.createReadStream('audio.mp3'),
  language: 'en'
});

console.log(response.text);
<?php
$ch = curl_init('https://api.tokenlab.sh/v1/audio/transcriptions');

$file = new CURLFile('audio.mp3', 'audio/mpeg', 'audio.mp3');

curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer sk-your-api-key'
    ],
    CURLOPT_POSTFIELDS => [
        'file' => $file,
        'model' => 'whisper-1',
        'language' => 'en'
    ]
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
echo $data['text'];
{
  "text": "Hello, this is a test of the transcription API."
}
{
  "task": "transcribe",
  "language": "english",
  "duration": 5.5,
  "text": "Hello, this is a test of the transcription API.",
  "segments": [
    {
      "id": 0,
      "start": 0.0,
      "end": 2.5,
      "text": "Hello, this is a test",
      "tokens": [...]
    }
  ]
}

翻訳

音声を英語に翻訳するには、translations endpoint を使用します:
response = client.audio.translations.create(
    model="whisper-1",
    file=audio_file
)