# 1. upload an audio or video file by link
curl -X POST https://api.rask.ai/api/library/v1/media/link \
-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
-d '{"link": "https://example.com/interview.mp3", "name": "interview"}'
# 2. create the project - speech recognition starts automatically
# src_lang is optional: leave it out and the language is detected
curl -X POST https://api.rask.ai/v2/projects \
-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
-d "{\"video_id\": \"$MEDIA_ID\", \"dst_lang\": \"es-mx\"}"# Read the transcript: one object per segment
curl -s https://api.rask.ai/v2/projects/$ID/transcription -H "Authorization: Bearer $TOKEN" \
| jq '.segments[] | {speaker, start, end, text: .src.text}'マルチパートフォームデータとして音声や動画ファイルを送信するか、YouTube、Googleドライブ、S3、Vimeo、または任意の直接リンクからURLを送信します。料金が発生する前に、メディアIDとファイルの詳細情報を取得できます。
メディアIDを video_id として渡し、翻訳先の言語を指定します。必要に応じて、元の言語や話者の人数も追加してください。すぐに認識が開始されます。
翻訳されたメディアの処理が続行されている間、セグメントの準備ができ次第、すぐに原稿を確認できます。プロジェクトが完了したら、字幕ファイルとメディアファイルをダウンロードしてください。
# pip install git+ssh://[email protected]/braskai/rask-sdk.git@main
import asyncio
from rask_sdk import clients, enums, schemas
async def main():
client = clients.RaskSDKClient(client_id=CLIENT_ID, client_secret=CLIENT_SECRET)
media = await client.create_media_link(data=schemas.MediaCreateLink(link="https://example.com/interview.mp3"))
while media.status is enums.MediaStatus.PROCESSING:
await asyncio.sleep(5)
media = await client.get_media(media_id=media.id)
# src_lang omitted: the source language is detected automatically
job = await client.create_project(data=schemas.ProjectCreate(video_id=media.id, dst_lang="es-mx"))
while job.status is not enums.ProjectStatus.MERGING_DONE:
await asyncio.sleep(10)
job = await client.get_project(project_id=job.id)
transcript = await client.get_project_transcription(project_id=job.id)
for seg in transcript.segments:
print(seg.start, seg.end, seg.speaker, seg.src.text)
asyncio.run(main())import time, requests
AUTH = "https://rask-prod.auth.us-east-2.amazoncognito.com/oauth2/token"
API = "https://api.rask.ai"
token = requests.post(AUTH, auth=(CLIENT_ID, CLIENT_SECRET),
data={"grant_type": "client_credentials"}).json()["access_token"]
h = {"Authorization": f"Bearer {token}"}
with open("interview.mp3", "rb") as f:
media = requests.post(f"{API}/api/library/v1/media", headers=h,
params={"kind": "audio"}, files={"data": f}).json()
while media["status"] == "processing":
time.sleep(5)
media = requests.get(f"{API}/api/library/v1/media/{media['id']}", headers=h).json()
pid = requests.post(f"{API}/v2/projects", headers=h, json={
"video_id": media["id"], "dst_lang": "es-mx", "num_speakers": 2}).json()["id"]
while requests.get(f"{API}/v2/projects/{pid}", headers=h).json()["status"] != "merging_done":
time.sleep(10)
# write the source transcript as an .srt file
segments = requests.get(f"{API}/v2/projects/{pid}/transcription", headers=h).json()["segments"]
with open("interview_en.srt", "w") as out:
for i, s in enumerate(segments, 1):
out.write(f"{i}\n{s['start']} --> {s['end']}\n{s['speaker']}: {s['src']['text']}\n\n")// no dependencies, Node 18+ global fetch
const API = 'https://api.rask.ai';
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
const auth = await fetch('https://rask-prod.auth.us-east-2.amazoncognito.com/oauth2/token', {
method: 'POST',
headers: { Authorization: 'Basic ' + btoa(`${CLIENT_ID}:${CLIENT_SECRET}`) },
body: new URLSearchParams({ grant_type: 'client_credentials' }),
}).then((r) => r.json());
const h = { Authorization: `Bearer ${auth.access_token}`, 'Content-Type': 'application/json' };
const call = (method, path, body) => fetch(API + path, { method, headers: h, body: body && JSON.stringify(body) }).then((r) => r.json());
let media = await call('POST', '/api/library/v1/media/link', { link: 'https://example.com/webinar.mp4' });
while (media.status === 'processing') { await sleep(5000); media = await call('GET', `/api/library/v1/media/${media.id}`); }
let p = await call('POST', '/v2/projects', { video_id: media.id, src_lang: 'en', dst_lang: 'de-de' });
while (p.status !== 'merging_done') { await sleep(10000); p = await call('GET', `/v2/projects/${p.id}`); }
const { segments } = await call('GET', `/v2/projects/${p.id}/transcription`);
segments.forEach((s) => console.log(`[${s.start}] ${s.speaker}: ${s.src.text}`));
console.log(p.translation_vtt_path); // German subtitles for your player# 1. token (valid 1 hour - cache and reuse it)
TOKEN=$(curl -s -X POST https://rask-prod.auth.us-east-2.amazoncognito.com/oauth2/token \
-u "$CLIENT_ID:$CLIENT_SECRET" -d "grant_type=client_credentials" | jq -r .access_token)
# 2. upload a local audio file
MEDIA_ID=$(curl -s -X POST "https://api.rask.ai/api/library/v1/media?kind=audio" \
-H "Authorization: Bearer $TOKEN" -F "data=@podcast_episode.mp3" | jq -r .id)
# 3. create the project once the media status is ready
ID=$(curl -s -X POST https://api.rask.ai/v2/projects \
-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
-d "{\"video_id\": \"$MEDIA_ID\", \"dst_lang\": \"fr-fr\"}" | jq -r .id)
# 4. when status is merging_done, read the transcript with speaker labels
curl -s https://api.rask.ai/v2/projects/$ID/transcription -H "Authorization: Bearer $TOKEN" \
| jq -r '.segments[] | "\(.start) \(.speaker): \(.src.text)"'<?php
use GuzzleHttp\Client;
$http = new Client(['base_uri' => 'https://api.rask.ai']);
$json = fn($r) => json_decode($r->getBody(), true);
$auth = $json((new Client)->post('https://rask-prod.auth.us-east-2.amazoncognito.com/oauth2/token',
['auth' => [$clientId, $clientSecret], 'form_params' => ['grant_type' => 'client_credentials']]));
$h = ['Authorization' => 'Bearer ' . $auth['access_token']];
$media = $json($http->post('/api/library/v1/media/link', ['headers' => $h, 'json' => [
'link' => 'https://example.com/interview.mp3']]));
while ($media['status'] === 'processing') {
sleep(5);
$media = $json($http->get("/api/library/v1/media/{$media['id']}", ['headers' => $h]));
}
$p = $json($http->post('/v2/projects', ['headers' => $h, 'json' => [
'video_id' => $media['id'], 'dst_lang' => 'es-mx']]));
while ($p['status'] !== 'merging_done') {
sleep(10);
$p = $json($http->get("/v2/projects/{$p['id']}", ['headers' => $h]));
}
$t = $json($http->get("/v2/projects/{$p['id']}/transcription", ['headers' => $h]));
foreach ($t['segments'] as $s) {
echo $s['start'], ' ', $s['speaker'], ': ', $s['src']['text'], PHP_EOL;
}{"segments": [
{"speaker": "SPEAKER_00", "start": "00:00:00,320", "end": "00:00:07,316", "status": "done",
"src": {"text": "Thanks for joining us. Let's start with the new release.", "lang": "en"},
"dst": {"text": "Gracias por acompañarnos. Empecemos con la nueva versión.", "lang": "es-mx"}},
{"speaker": "SPEAKER_01", "start": "00:00:07,640", "end": "00:00:11,900", "status": "done",
"src": {"text": "Sure. The biggest change is the reporting view.", "lang": "en"},
"dst": {"text": "Claro. El cambio más grande es la vista de reportes.", "lang": "es-mx"}}
]}

es-mx および es-es 同様に機能します。プロジェクトには glossary_versionが記録されるため、後から編集を行っても、完了した作業が勝手に変更されることはありません。はい。音声認識は、すべてのRaskプロジェクトの最初のステップです。音声や動画をアップロードしてプロジェクトを作成すると、GET /v2/projects/{id}/transcriptionから、話者ラベルとタイムスタンプ付きのセグメント単位で文字起こしを確認できます。同じプロジェクトで文字起こしの翻訳を行い、字幕や音声の吹き替えを出力することも可能です。
APIでは75の言語を入力言語として利用できます。src_langを空欄にすると言語が自動で検出されますが、「en」や「de」のように2文字のコードを指定することも可能です。文字起こし結果は、135以上の言語や地域設定に翻訳できます。
はい。ポッドキャスト、インタビュー、録音された通話などのMP3、WAV、FLAC、M4A形式の音声ファイルをアップロードすれば、動画と同様に文字起こしが行われます。
はい。異なる話者は自動で検出され、各セグメントにはSPEAKER_XX形式の話者ラベルが付与されます。人数があらかじめ分かっている場合はnum_speakersを指定でき、API経由で任意のセグメントの話者を修正することも可能です。
いいえ。タイムスタンプはセグメント単位です。各セグメントにはHH:MM:SS,mmm形式の開始時刻と終了時刻が割り当てられ、これがキャプションや字幕で使用されるタイミングになります。すべての単語にタイムスタンプが必要な場合は、専用の音声認識APIをお選びください。
いいえ。Raskは、録音・録画済みの完全な音声および動画の文字起こしを行います。話している最中にテキストを表示する必要があるリアルタイムのキャプション、音声エージェント、会話型AI、コンタクトセンターなどの用途には、ストリーミング音声認識APIが適しています。
精度は音声の状態によって異なります。マイクの品質、アクセント、話者の声の重なり、背景の雑音などが影響します。実際の録音データのサンプルでAPIをテストし、公開や翻訳を行う前にAPI経由でセグメントを修正することをおすすめします。
認識機能にカスタム単語リストを直接読み込ませることはできません。特定の単語を修正するには、セグメントのエンドポイントを使用します。文字起こしが翻訳される際は、用語集機能によって製品名、固有名詞、専門用語が一貫して保たれます。
完了したプロジェクトには、ターゲット言語のSRTおよびVTT形式の字幕ファイルが含まれます。元の言語の文字起こしは、開始時間と終了時間を含むJSONセグメントとして提供され、数行のコードを書くことでSRTに変換できます。
はい。トランスクリプトのインポートに対応しているプランでは、プロジェクト作成時に、既存の元のトランスクリプト、翻訳済みの承認済みテキスト、またはその両方をSRTファイルやタイム付きテキストとして追加できます。Raskでは、元の原稿の翻訳や、承認済み翻訳を使用した音声の吹き替えを行うことができます。
プロジェクトの料金は、音声や動画の再生時間(分)単位で計算され、端数は切り上げられます。利用できる時間はRaskアプリの共通のプールから消費されます。料金には、文字起こし、翻訳、音声の吹き替え、字幕が含まれます。対象となる標準プランでは、追加の時間は1分あたり3ドルとなります。企業向けプランの価格は、ご契約内容に合わせて個別に調整されます。文字起こしのみが必要な場合は、専用の音声文字変換APIの方が安価です。
Raskアプリではクレジットカード不要の無料トライアルから始められ、お手持ちのファイルで文字起こしや翻訳をお試しいただけます。APIのご利用はCreator Pro、Business、Enterpriseプランで可能で、機能はプランによって異なります。
APIアクセスは、クリエイタープロ、ビジネス、およびエンタープライズの各プランでご利用いただけます。利用できる機能はプランによって異なります。アプリ内でクライアントIDとシークレットを生成すれば、すぐにAPIの呼び出しを開始できます。エンタープライズ向けの契約条件、大量利用時の割引、カスタム言語の対応については、弊社のチームまでお問い合わせください。