音声文字起こし API (POST /v1/audio/transcriptions)
音声ファイルを指定したフォーマットのテキストに文字起こしします。OpenAI API プロトコル仕様に完全準拠しています。
HTTP リクエスト
http
POST /v1/audio/transcriptions
Authorization: Bearer sk-oneasr-...
Content-Type: multipart/form-dataリクエストボディのフィールド仕様 (Multipart Form)
| フィールド名 | 型 | 必須 | パラメータ説明 |
|---|---|---|---|
file | binary | 必須 | 音声ファイルのバイナリデータ (mp3, mp4, wav, m4a, ogg, webm, flac など)。 |
model | string | 必須 | 呼び出すエンジン / モデル名(例: faster-whisper, qwen, whisper-1)。 |
language | string | 任意 | ISO-639-1 言語コード(例: zh, en, ja, de, ko)。 |
prompt | string | 任意 | 文字起こしのスタイルや専門用語を誘導するコンテキストプロンプト。 |
response_format | string | 任意 | レスポンスデータ形式:json (デフォルト), text, srt, verbose_json, vtt。 |
temperature | number | 任意 | サンプリング温度パラメータ (0.0 〜 1.0、デフォルト: 0.0)。 |
timestamp_granularities | array | 任意 | タイムスタンプ粒度:["word"] (単語単位), ["segment"] (文単位)。 |
呼び出しサンプルコード
cURL
bash
curl -X POST http://localhost:8000/v1/audio/transcriptions -H "Authorization: Bearer sk-oneasr-v1-xxx" -F file="@meeting.mp3" -F model="faster-whisper" -F language="ja" -F response_format="verbose_json"Python (公式 OpenAI SDK)
python
from openai import OpenAI
client = OpenAI(
base_url="http://localhost:8000/v1",
api_key="sk-oneasr-v1-xxx"
)
with open("speech.mp3", "rb") as f:
result = client.audio.transcriptions.create(
model="faster-whisper",
file=f,
response_format="verbose_json"
)
print(result.text)レスポンス例 (verbose_json)
json
{
"task": "transcribe",
"language": "japanese",
"duration": 5.24,
"text": "OneASR 高性能プライベート音声認識ゲートウェイへようこそ。",
"segments": [
{
"id": 0,
"seek": 0,
"start": 0.0,
"end": 5.2,
"text": "OneASR 高性能プライベート音声認識ゲートウェイへようこそ。",
"tokens": [50364, 4843, 284, 1530, 50589],
"temperature": 0.0,
"avg_logprob": -0.12,
"compression_ratio": 1.1,
"no_speech_prob": 0.001
}
]
}