APIドキュメント
RESTful APIで、AudioToTextAIの文字起こしをアプリケーションに組み込めます。
認証
すべての API 要求は API 鍵を使った認証を必要とします。API 鍵をメールに含めてください。 Authorization ヘッダ:
Authorization: Bearer YOUR_API_KEY
API キーは、 アカウント設定.
APIキーを秘密にしておく クライアント側のコードや公開リポジトリに それを暴露しないでください。
音声を文字起こし
POST
/api/v1/transcribe/
転写するオーディオファイルをアップロードします。API は結果をポールするためのジョブ ID を返します。
リクエストボディ (マルチパート/フォームデータ)
| パラメータ | タイプ | 説明 |
|---|---|---|
file * |
ファイル | 音声ファイル (MP3、WAV、M4A、FLAC、OGG、またはビデオファイル) |
model |
文字列 | 使用するモデル: whisper-large-v3 (デフォルト) または whisper-turbo |
language |
文字列 | ISO 639-1 言語コード (例: "en", "es") 自動検出のため空にしておく |
timestamps |
ブルアン | セグメントのタイムスタンプを含む (標準: true) |
word_timestamps |
ブルアン | ワードレベルのタイムスタンプを含む(W) (デフォルト: false) |
summary |
ブルアン | AI 概要を生成 (デフォルト: false) |
vocabulary |
アレイ | 精度を向上させるためのカスタム語彙 (JSON アレイまたはコンマ分離) |
例の要求
curl -X POST https://audiototextai.com/api/v1/transcribe/ \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "file=@audio.mp3" \
-F "summary=true" \
-F "language=en"
応答
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"status": "processing",
"estimated_credits": 5.5
}
URL から転写
POST
/api/v1/transcribe/url/
URL から音声を転写します。音声/ビデオ URL と YouTube リンクを直接サポートします。
リクエストボディ (JSON)
{
"url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
"summary": true
}
例の要求
curl -X POST https://audiototextai.com/api/v1/transcribe/url/ \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com/podcast.mp3", "summary": true}'
転写結果を取得
GET
/api/v1/transcribe/{id}/
転写ジョブの状態と結果を検索します。
クエリパラメータ
| パラメータ | タイプ | 説明 |
|---|---|---|
segments |
ブルアン | タイムスタンプ付きの詳細なセグメントを含む (標準: false) |
応答 (処理中)
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"status": "processing",
"progress": 45
}
応答 (完了)
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"status": "completed",
"transcript": "Hello and welcome to today's podcast...",
"duration_seconds": 1847.5,
"language": "en",
"credits_used": 31.2,
"summary": "This podcast discusses the future of AI...",
"topics": ["artificial intelligence", "technology", "future"],
"segments": [
{
"start": 0.0,
"end": 5.2,
"text": "Hello and welcome to today's podcast.",
"confidence": 0.98
}
]
}
サポートされている言語の一覧
GET
/api/v1/languages/
転写にサポートされている言語の一覧を取得します。
応答
{
"languages": [
{"code": "", "name": "Auto-detect"},
{"code": "en", "name": "English"},
{"code": "es", "name": "Spanish"},
{"code": "fr", "name": "French"},
...
]
}
ウェブフック
これは、プログラムの実行中に、プログラムの
追加 webhook_url 転写要求のパラメータ:
curl -X POST https://audiototextai.com/api/v1/transcribe/ \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "file=@audio.mp3" \
-F "webhook_url=https://yourapp.com/transcription-complete"
転写が完了したら、結果を webhook URL に POST します。
POST https://yourapp.com/transcription-complete
Content-Type: application/json
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"status": "completed",
"transcript": "...",
...
}
エラーハンドリング
APIは標準HTTP状態コードを使用し,エラー詳細をJSON形式で返す。
| ステータス | 説明 |
|---|---|
400 |
不正な要求: 無効なパラメータまたは必要なフィールドが欠けています |
401 |
認証されていません: API キーが無効または欠落しています |
402 |
支払いが必要: クレジット不足 |
404 |
ファイルが見つかりません |
500 |
サーバエラー: 何かおかしいことが起きました |
エラー応答フォーマット
{
"error": "insufficient_credits",
"message": "You have 10 credits remaining but this transcription requires 30 credits."
}
コードの例
Python
import requests
API_KEY = "your-api-key"
BASE_URL = "https://audiototextai.com/api/v1"
# Upload and transcribe
with open("audio.mp3", "rb") as f:
response = requests.post(
f"{BASE_URL}/transcribe/",
headers={"Authorization": f"Bearer {API_KEY}"},
files={"file": f},
data={"summary": "true"}
)
job = response.json()
print(f"Job ID: {job['id']}")
# Poll for results
import time
while True:
result = requests.get(
f"{BASE_URL}/transcribe/{job['id']}/",
headers={"Authorization": f"Bearer {API_KEY}"},
params={"segments": "true"}
).json()
if result["status"] == "completed":
print(result["transcript"])
break
elif result["status"] == "failed":
print(f"Error: {result['error_message']}")
break
time.sleep(5)
JavaScript (Node.js)
const fs = require('fs');
const axios = require('axios');
const FormData = require('form-data');
const API_KEY = 'your-api-key';
const BASE_URL = 'https://audiototextai.com/api/v1';
async function transcribe(filePath) {
const form = new FormData();
form.append('file', fs.createReadStream(filePath));
form.append('summary', 'true');
const { data: job } = await axios.post(
`${BASE_URL}/transcribe/`,
form,
{
headers: {
'Authorization': `Bearer ${API_KEY}`,
...form.getHeaders()
}
}
);
console.log(`Job ID: ${job.id}`);
// Poll for results
while (true) {
const { data: result } = await axios.get(
`${BASE_URL}/transcribe/${job.id}/`,
{ headers: { 'Authorization': `Bearer ${API_KEY}` } }
);
if (result.status === 'completed') {
return result;
} else if (result.status === 'failed') {
throw new Error(result.error_message);
}
await new Promise(r => setTimeout(r, 5000));
}
}
transcribe('./audio.mp3').then(console.log);