Documents & mediaSpeech to Text
Speech to Text API: Transcribe Audio and Video with Timestamps and SRT
Speech to text API tutorial: transcribe audio and video files with Python, with timestamps, SRT and WebVTT subtitles, speaker labels and an AI summary.
Transcription looks solved until you put it in production. The open-source Whisper models run well on a GPU you have to provision; hosted endpoints cap the file size, so an hour-long episode has to be cut, sent in pieces and stitched back together; subtitles need timestamps in a format players accept; and the summary someone asks for next means a second model call over the whole transcript.
A speech to text API should hide that plumbing: send a file, get the text, the timings, the subtitle files and, when you ask, the summary. This article shows how the Audio & Video Transcription API does it, what comes back field by field, and where it stops being the right tool.
How a speech-to-text API handles long recordings
The hard part of long-form transcription is length, not accuracy on a clean sentence. Speech models are trained on short windows (Whisper on 30-second segments) and long files are processed piece by piece. Hand a language-model-based transcriber twenty minutes in one call and it can start to loop: the same sentence repeated, timestamps running past the end of the file.
This API cuts every file into parts of at most five minutes. The audio track is copied as-is when the model reads the codec (MP3, AAC, Ogg, FLAC, WAV), and re-encoded to Opus otherwise. All parts are transcribed at the same time, then the timestamps are shifted back onto one timeline. Two guards catch a model that goes wrong: the output of each part is capped in proportion to its duration, and lines timed past the end of their part are dropped. A five-minute file and a one-hour file therefore take about the same time once downloaded; one hour usually comes back in about a minute.
| Self-hosted Whisper | Hosted transcription endpoint | This API | |
|---|---|---|---|
| Setup | GPU, model weights, a queue | API key | API key |
| Long files | Your chunking code | Often a size cap per request (25 MB at OpenAI) | Split and parallelised for you, up to 120 minutes |
| Subtitles | Your formatting code | SRT/VTT on some providers | SRT and WebVTT in the same response |
| Speaker labels | A second model (diarisation) | Varies | speakers: true |
| Summary and chapters | A second call to an LLM | Rarely | summary: true |
Transcribe an audio file from a URL with Python
POST /v1/transcription/transcribe takes a JSON body with the direct link to a file. The recording here is a public-domain LibriVox reading of Kate Chopin's three-minute fable Emancipation:
import requests
HOST = "audio-video-transcription-speech-to-text.p.rapidapi.com"
API = f"https://{HOST}/v1/transcription"
HEADERS = {"x-rapidapi-key": "YOUR_API_KEY", "x-rapidapi-host": HOST}
payload = {
"url": "https://archive.org/download/short_story_047_1102_librivox/shortstory047_emancipation_mgt_64kb.mp3",
"formats": ["srt", "vtt"],
}
response = requests.post(
f"{API}/transcribe", headers=HEADERS, json=payload, timeout=150
)
response.raise_for_status()
transcript = response.json()
print(
transcript["language"], transcript["duration_seconds"], transcript["minutes_billed"]
)
for segment in transcript["segments"][:3]:
print(f"{segment['start']:>6.1f} {segment['text']}")
The same call with curl:
curl -X POST "https://audio-video-transcription-speech-to-text.p.rapidapi.com/v1/transcription/transcribe" \
-H "X-RapidAPI-Key: YOUR_API_KEY" \
-H "X-RapidAPI-Host: audio-video-transcription-speech-to-text.p.rapidapi.com" \
-H "Content-Type: application/json" \
-d '{"url": "https://archive.org/download/short_story_047_1102_librivox/shortstory047_emancipation_mgt_64kb.mp3", "formats": ["srt", "vtt"]}'
The real response came back in 7.2 seconds, download included. text is cut after its first sentences, 3 of the 25 segments are shown, and the subtitle files are trimmed:
{
"source": "https://dn710804.ca.archive.org/0/items/short_story_047_1102_librivox/shortstory047_emancipation_mgt_64kb.mp3",
"duration_seconds": 180.35,
"minutes_billed": 3,
"language": "en",
"text": "Emancipation, a life fable by Kate Chopin. … This is a LibriVox recording. All LibriVox recordings are in the public domain. … There was once an animal born into this world, and opening his eyes upon life, he saw above and about him confining walls, and before him were bars of iron, through which came air and light from without. This animal was born in a cage. …",
"segments": [
{ "start": 0.0, "end": 6.0, "text": "Emancipation, a life fable by Kate Chopin." },
{ "start": 11.0, "end": 15.0, "text": "All LibriVox recordings are in the public domain." },
{ "start": 172.0, "end": 180.35, "text": "This recording is in the public domain." }
],
"subtitles": {
"srt": "1\n00:00:00,000 --> 00:00:06,000\nEmancipation, a life fable by Kate Chopin.\n\n…",
"vtt": "WEBVTT\n\n00:00:00.000 --> 00:00:06.000\nEmancipation, a life fable by Kate Chopin.\n\n…"
}
}
Timestamps, segments and billed minutes
| Field | Meaning |
|---|---|
source |
The final URL after redirects (archive.org sends the request to a storage node) or the uploaded file name |
duration_seconds |
Length of the audio track |
minutes_billed |
Started minutes, the basis of the credits |
language |
ISO 639-1 code of the main spoken language, detected automatically |
text |
The whole transcript: one paragraph, or one S1: … line per segment with speaker labels |
segments |
start and end in seconds, text, and speaker when labels are on |
subtitles |
srt and/or vtt, as text, when asked in formats |
insights |
The summary block, when summary is on |
Minutes are counted as started minutes with one second of grace: 180.35 seconds is three minutes, and a 60.01-second file (decoders often pad a few milliseconds) is still one. Segment boundaries follow sentences and are given to the second; they are not word-level timings.
The transcript stays in the language spoken. Pass language ("fr", "German") for very short clips or recordings that mix languages; otherwise detection is automatic.
SRT and WebVTT subtitles from the same call
Both files are built from the same segments, so they always agree with segments. The two formats differ in small ways that players are strict about:
| SRT (SubRip) | WebVTT | |
|---|---|---|
| Header | None | WEBVTT on the first line |
| Cue number | Required | Optional (omitted here) |
| Time format | 00:00:06,000 (comma) |
00:00:06.000 (dot) |
| Speaker tag | [S1] prefix |
<v S1> voice tag |
| Typical use | Video editors, YouTube, social uploads | HTML5 <track> elements in browsers |
The first cues of the real SRT file from the call above:
1
00:00:00,000 --> 00:00:06,000
Emancipation, a life fable by Kate Chopin.
2
…
3
00:00:09,000 --> 00:00:11,000
This is a LibriVox recording.
4
00:00:11,000 --> 00:00:15,000
All LibriVox recordings are in the public domain.
Save them with pathlib.Path("episode.srt").write_text(transcript["subtitles"]["srt"], encoding="utf-8"). One limit to know: cues follow the sentences of the segments, and a long sentence makes a long cue. In this file, the sixth cue runs 16 seconds. Common subtitle guidelines aim for about 42 characters per line and two lines per cue, so for broadcast-style captions, split long cues at punctuation before publishing.
Speaker labels and an AI summary
Two options add work to the same call. speakers: true labels every segment S1, S2… in order of appearance (2 credits per minute instead of 1). summary: true reads the finished transcript and returns a paragraph, key points, chapters with timestamps and the action items said aloud (+1 credit per started five minutes, 2 at least).
payload = {
"url": "https://archive.org/download/short_story_047_1102_librivox/shortstory047_beforethelaw_ava_64kb.mp3",
"speakers": True,
"summary": True,
"formats": ["srt"],
}
The real response on Kafka's Before the Law, shortened:
{
"duration_seconds": 309.37,
"minutes_billed": 6,
"language": "en",
"text": "S1: Before the Law, by Franz Kafka.\nS1: Translated by Ian Johnston.\n...",
"segments": [
{ "start": 0.0, "end": 3.0, "speaker": "S1", "text": "Before the Law, by Franz Kafka." },
{ "start": 3.0, "end": 6.0, "speaker": "S1", "text": "Translated by Ian Johnston." }
],
"speakers": ["S1"],
"insights": {
"summary": "A LibriVox reading of Franz Kafka's 'Before the Law'. A man from the country waits all his life at the gate of the law...",
"key_points": ["A gatekeeper refuses the man entry", "The man waits for years and bribes the gatekeeper"],
"chapters": [
{ "start": "00:00:00", "title": "Introduction" },
{ "start": "00:00:18", "title": "Before the Law" }
],
"action_items": []
}
}
The 5 minutes 9 seconds count as 6 minutes, so this call used 12 credits for the transcript with speakers plus 2 for the summary. The summary only uses what is said, and its chapters reuse the transcript's own timestamps, which makes them usable as podcast chapter markers or YouTube description timestamps. action_items is empty here because a short story assigns no tasks; on a meeting recording it lists the decisions and follow-ups.
Speaker labels are anonymous and assigned per five-minute part. On a long recording with several voices, the person labelled S1 in one part can be S2 in the next; check them before you publish "who said what" on a multi-hour panel.
Upload a file or a video instead of a link
Files that are not online go to POST /v1/transcription/transcribe/upload as multipart/form-data, with the same options as form fields:
with open("meeting.m4a", "rb") as f:
response = requests.post(
f"{API}/transcribe/upload",
headers=HEADERS,
files={"file": ("meeting.m4a", f)},
data={"speakers": "true", "summary": "true", "formats": ["srt", "vtt"]},
timeout=150,
)
response.raise_for_status()
Uploads are capped at 30 MB, about an hour of MP3 at 64 kbit/s; by URL, files go up to 150 MB. Both stop at 120 minutes. The file type is detected from its first bytes, not its extension, and MP3, M4A, AAC, WAV, OGG, Opus, FLAC, WEBM, MP4, MOV and MKV all work. For video, only the sound track is extracted and sent, so a 100 MB screen recording costs the same per minute as its audio would.
Batch-transcribe a list of recordings with retries
The script below transcribes a list of episode URLs four at a time, writes a .txt, an .srt and the summary for each, and records failures with their error code. max_minutes refuses files longer than you expect, before any credit is spent.
import json
import pathlib
import time
from concurrent.futures import ThreadPoolExecutor
import requests
HOST = "audio-video-transcription-speech-to-text.p.rapidapi.com"
API = f"https://{HOST}/v1/transcription"
HEADERS = {"x-rapidapi-key": "YOUR_API_KEY", "x-rapidapi-host": HOST}
OUT = pathlib.Path("transcripts")
OUT.mkdir(exist_ok=True)
def transcribe(url: str, attempts: int = 3) -> dict:
payload = {"url": url, "summary": True, "formats": ["srt"], "max_minutes": 90}
for attempt in range(attempts):
try:
r = requests.post(
f"{API}/transcribe", headers=HEADERS, json=payload, timeout=150
)
except (requests.Timeout, requests.ConnectionError):
time.sleep(10 * 2**attempt)
continue
if r.status_code == 503: # ai_error, capacity_exhausted: not billed
time.sleep(int(r.headers.get("Retry-After", 10 * 2**attempt)))
continue
if r.status_code == 429:
raise SystemExit("Daily limit reached: resets at 00:00 UTC.")
return r.json() # a transcript, or {"error": {...}} for a 400
return {"error": {"code": "gave_up"}}
urls = [line.strip() for line in open("episodes.txt", encoding="utf-8") if line.strip()]
with ThreadPoolExecutor(max_workers=4) as pool:
for number, (url, result) in enumerate(zip(urls, pool.map(transcribe, urls)), 1):
stem = OUT / f"{number:03d}"
if "error" in result:
print(url, result["error"]["code"])
continue
stem.with_suffix(".txt").write_text(result["text"], encoding="utf-8")
stem.with_suffix(".srt").write_text(
result["subtitles"]["srt"], encoding="utf-8"
)
stem.with_suffix(".json").write_text(
json.dumps(result["insights"], ensure_ascii=False, indent=2),
encoding="utf-8",
)
Production notes:
- Timeouts. Allow the download time plus 15 to 30 seconds; 150 seconds covers a long file on a fast host.
- Retry 503, not 400.
unsupported_file,media_too_longandno_speechdescribe the file.site_unreachablemay succeed on the next run. - Store the segments. Keep
segmentsrather than onlytext: search hits can then jump to the right second of the recording. - Podcast feeds. To get the episode MP3 links from an RSS feed or an Apple Podcasts page first, the Podcast API reads feeds and can transcribe episodes too.
What it costs
One credit per started minute of audio, two with speaker labels; the summary adds one per started five minutes (two at least); subtitles and the language hint are free. Failed calls are not billed.
| Plan | Price per month | Credits | In practice |
|---|---|---|---|
| BASIC | Free, no card | 5 per day | 5 minutes of audio a day, 5 minutes per file at most |
| PRO | $4.99 | 1,200 | 20 hours of audio (about $0.0042 a minute) |
| ULTRA | $14.99 | 3,600 | 60 hours |
| MEGA | $49.99 | 12,000 | 200 hours |
An hour-long episode with a summary uses 72 credits, about $0.30 on PRO; beyond the quota, paid plans continue at $0.05 per credit. For reference, OpenAI's hosted transcription is listed at $0.006 a minute, and transcription actors on Apify charge from $0.006 up to $0.048 a minute. Plans are on the API page, parameters in the reference.
Run it without code on Apify
The same engine runs as an Apify Actor, Audio & Video Transcription - Speech to Text. Paste file links, or the dataset ID of a podcast or RSS scraper, switch on speaker labels, the summary or subtitles, and export one row per file. It charges $0.0035 per minute transcribed, $0.002 per minute with speaker labels and $0.0005 per minute summarised; files that cannot be read are not charged.
What the speech to text API does not do
- No YouTube, Spotify or web pages. It needs the media file itself, by direct link or upload.
- No real-time streaming. Whole files only; live captioning needs a streaming API.
- No word-level timestamps. Segments are timed to the second, sentence by sentence.
- No speaker names. Labels are
S1,S2…, assigned per five-minute part. - No translation. The transcript stays in the spoken language.
- 120 minutes per file. Split longer recordings; the free plan stops at 5 minutes per file.
Frequently asked questions
How do I transcribe an audio file with Python?
Send the file's URL to POST /v1/transcription/transcribe, or upload it as multipart to /transcribe/upload, with requests, then read text and segments from the JSON. Add "formats": ["srt"] to get a subtitle file in the same response.
How do I generate SRT subtitles from an audio or video file?
Ask for "formats": ["srt"] (or "vtt" for WebVTT). The response carries the subtitle file as text, built from the timestamped segments; write it to a .srt file. Split long cues at punctuation if your captions need short lines.
Which languages does the transcription API support?
The spoken language is detected automatically and the transcript stays in it, with an ISO 639-1 code in language. Pass language for short clips or mixed-language recordings. Accuracy is highest on clear speech in widely spoken languages.
How long does it take to transcribe one hour of audio?
Usually about a minute: the download time plus 15 to 30 seconds, because the file is split into five-minute parts that are all transcribed at the same time.
Is my audio stored?
No. Files are downloaded, transcribed and discarded; neither the audio nor the transcript is kept by the API. The AI provider may retain requests temporarily for abuse monitoring.
Get started
Audio & Video Transcription API
Fast speech to text for audio and video: timestamps, speaker labels, SRT/VTT and AI summaries.
- Speech to Text
- Transcription
- Subtitles
- Python
- Podcasting



