# Speech to Text Transcription - Whisper, Audio to Text (`stas_k/speech-to-text-transcription`) Actor

Most transcription actors charge for an error page or an hour of silence and hand back empty text. Here every file gets a row that says what happened, and only a delivered transcript is charged.

- **URL**: https://apify.com/stas_k/speech-to-text-transcription.md
- **Developed by:** [Stas K](https://apify.com/stas_k) (community)
- **Categories:** AI, Videos, Automation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 1 bookmarks
- **User rating**: No ratings yet

## Pricing

$6.00 / 1,000 audio files

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Speech to Text Transcription - Whisper, Audio to Text

Turns audio files into text with Whisper, on the actor's own CPU, with no API key and no
per minute bill from a third party. Give it a list of http(s) addresses of audio files and
get one row per file: the transcript, the detected language, the duration, segments with
timestamps and optionally ready SRT and VTT.

### Why this actor exists

The complaint in this niche is always the same: a run comes back green, the dataset is
empty or full of nonsense, and the buyer paid for it. It happens for boring reasons that a
plain Whisper wrapper never checks:

- the URL answers 404 or a login page, and the HTML is fed to the model as if it were audio;
- the file is two hours of silence and the model invents sentences to fill it;
- the file is a two hour podcast and the run dies at the platform timeout with no summary;
- the file lives on `127.0.0.1` or in the container metadata and should never be read at all.

Here every input line gets a row. Either it is a transcript, or it is a status with a plain
reason, and only a delivered transcript is charged.

### What a run does

1. Checks the URL: only http(s), only a public address, and every redirect hop is checked
   again. A private or local address is refused before a socket is opened.
2. Downloads with a byte limit (`maxFileMb`, 100 MB by default).
3. Reads the duration from the container header before decoding anything, and refuses a
   file longer than `maxMinutesPerFile` (10 by default) with its real length in the row.
4. Decodes with PyAV to 16 kHz mono. Anything that is not audio becomes
   `NOT_CHECKED_UNSUPPORTED` and costs nothing.
5. Transcribes with the chosen Whisper model (all three are already inside the image, so a
   run never downloads weights), optionally skipping silence with voice activity detection.
6. Before a file starts, plans it with numbers measured on one thread plus a margin and
   the model load, and refuses the file when the platform clock cannot fit it: a free
   `NOT_CHECKED_TIME` row instead of a run killed in the middle of a file.
7. Writes the row and charges for it in one call, then repeats until the list, the file
   limit, the spending cap or the platform clock says stop.

### Pricing

Pay per event, `audio-transcribed`: **$0.01 for one delivered transcript**. A file that
comes back with any `NOT_CHECKED_*` status is free, including a file longer than the limit,
an oversized one, a dead link and an address that was refused. The platform charges compute
separately, and compute is the real cost of running Whisper yourself: memory in GB times
hours, so ten minutes of audio on `small` at 4096 MB is about 1.9 compute units and on
`base` about 0.8. Nothing is charged for a file the clock could not fit.

### Input

| Field | Meaning |
| --- | --- |
| `audioUrls` | http(s) addresses, one per line. mp3, wav, m4a, ogg, opus, flac, webm, mp4: anything PyAV opens. |
| `model` | `tiny`, `base` or `small` (default). `small` reads names and accented speech noticeably better. |
| `language` | Two or three letter code, or empty to detect it from the audio. |
| `maxMinutesPerFile` | Default 10, maximum 120. Longer files are refused, named with their real length, and not charged. |
| `maxFileMb` | Default 100. The download stops at the limit, so a huge file cannot eat the run. |
| `maxFiles` | Default 10, `0` means no limit. Files past the limit get a free `NOT_CHECKED_LIMIT` row. |
| `includeSegments` | Timestamped phrases in the row, default on. |
| `includeSubtitles` | Builds `srt` and `vtt` strings from the same segments, default off. |
| `vadFilter` | Drops silence and music before the model sees them, default on. |

### Output

A transcript row carries `status: TRANSCRIBED`, `text`, `language`, `languageProbability`,
`durationSecs`, `audioMinutes`, `model`, `charCount`, `wordCount`, `segments`, and `billable`.
Every other row keeps `index`, `url` and `fileName` and says what happened:

`NOT_CHECKED_INVALID_URL`, `NOT_CHECKED_PRIVATE_TARGET`, `NOT_CHECKED_FETCH_ERROR`,
`NOT_CHECKED_TOO_LARGE`, `NOT_CHECKED_UNSUPPORTED`, `NOT_CHECKED_TOO_LONG`,
`NOT_CHECKED_TIME`, `NOT_CHECKED_LIMIT`, `NOT_CHECKED_DUPLICATE`, `NOT_CHECKED_BILLING`,
`NOT_CHECKED_CAP`, `NOT_CHECKED_ERROR`.

The run summary lives in the key-value store under `RUN_SUMMARY-<runId>` with a plain
`RUN_SUMMARY` copy in the same run store, and it separates what happened to files from what
happened to money: `filesTranscribed`, `audioMinutes`, `chargedEvents`, `deliveredUncharged`,
`billingActive`, `stopReason`, `byStatus`. If the numbers ever fail to add up, the summary
says so in `counterMismatch` or `moneyMismatch` instead of rounding quietly.

### What this actor does not do

- No speaker diarization. One voice or five, the transcript does not say who spoke.
- No translation. It writes what was said, in the language it was said.
- No word level timestamps, only phrase level.
- No scraping of YouTube, Instagram or TikTok pages: the input is a direct media address.
  A page that is not audio comes back as `NOT_CHECKED_UNSUPPORTED`.
- No private or local addresses, by design, and no way to switch that off.

### Honest numbers

The same 11 second 16 kHz file, faster-whisper 1.2.1 with int8, on a laptop class CPU (so
not a promise about the platform's hardware):

| model | one thread | two threads |
| --- | --- | --- |
| `base` | 0.94 s of work per second of audio | 0.54 |
| `small` (default) | **2.31** | 1.37 |

Loading the model costs about 7 seconds, once per run. Worker threads follow the container
budget, one core per 4096 MB, so the default 4096 MB run gets **one** thread and the `small`
numbers in that column are the ones that apply.

That is the number that matters: `small` on one thread is 2.3 seconds of work per second of
audio, so a 10 minute file is about 23 minutes of compute, and `base` is about 9. Before each
file the actor plans with exactly these numbers, a 20 percent margin and the model load, and
refuses the file when the platform clock cannot fit it: a free `NOT_CHECKED_TIME` row and the
run stops by its own clock with `stopReason: deadline`, instead of being killed mid file.
For long recordings give the run 8192 MB (two threads, about 1.4 s per second on `small`, and
the wall time halves) or choose `base`.

### Development

```
python tests/test_audio.py   # 68 checks, real decoding, the address guard and the plan
python tests/test_main.py    # 132 checks, the money path on a fake Actor that follows apify 4.2
python -m src.main           # local run; without a price it refuses to give transcripts away
```

# Actor input Schema

## `audioUrls` (type: `array`):

One http(s) address per line, any format PyAV reads: mp3, wav, m4a, ogg, opus, flac, webm, mp4. Up to 10 files per run unless maxFiles says otherwise. A private address, a page that is not audio, an oversized file and a file longer than maxMinutesPerFile each come back as a free row with a status and the reason, so nothing disappears and nothing is charged for it.

## `model` (type: `string`):

All three models are already inside the image, so choosing one never downloads anything at run time. small reads accented speech and names noticeably better than base; tiny is for clean speech when speed matters more than the last percent of accuracy.

## `language` (type: `string`):

Two or three letter code such as en, de, uk, pl. Empty means the language is detected from the first seconds of audio and reported per file with its probability. Setting it is faster and stops a short file from being guessed wrong.

## `maxMinutesPerFile` (type: `integer`):

A file longer than this is not transcribed, not charged, and comes back as NOT_CHECKED_TOO_LONG with its real length, so a two hour recording cannot quietly eat the whole run.

## `maxFiles` (type: `integer`):

The list is cut here; files beyond the limit get a free NOT_CHECKED_LIMIT row. 0 means no limit.

## `maxFileMb` (type: `integer`):

Download stops at this many bytes. A larger file is not transcribed and not charged, and the row says how big it was.

## `includeSegments` (type: `boolean`):

Adds a segments list to every transcript: start, end and text of each spoken phrase. Turn it off when only the plain text matters and the dataset should stay small.

## `includeSubtitles` (type: `boolean`):

Builds ready to use subtitles from the same segments, as srt and vtt strings in the row.

## `vadFilter` (type: `boolean`):

Drops long silences and music before the model sees them. On a mostly silent file this is the difference between a transcript and a wall of invented sentences, and it makes the run faster.

## Actor input object example

```json
{
  "audioUrls": [
    "https://raw.githubusercontent.com/openai/whisper/main/tests/jfk.flac",
    "https://raw.githubusercontent.com/ggerganov/whisper.cpp/master/samples/jfk.wav"
  ],
  "model": "small",
  "maxMinutesPerFile": 10,
  "maxFiles": 10,
  "maxFileMb": 100,
  "includeSegments": true,
  "includeSubtitles": false,
  "vadFilter": true
}
```

# Actor output Schema

## `dataset` (type: `string`):

One row per input line, in input order. A transcribed file carries status TRANSCRIBED, text, charCount, wordCount, language and languageProbability (how sure the model is about the detected language), model, durationSecs, audioMinutes, bytes, contentType, fileName, url, index, billable, segments with start, end and text of every spoken phrase (when includeSegments is on), and srt plus vtt strings (when includeSubtitles is on). Every file that was not transcribed keeps its identity (index, url, fileName) and carries a status and a plain reason instead of text: NOT_CHECKED_INVALID_URL (the line is not an http or https address), NOT_CHECKED_PRIVATE_TARGET (a local or private address, refused before any request), NOT_CHECKED_FETCH_ERROR (the server answered with an error or a timeout), NOT_CHECKED_TOO_LARGE (over maxFileMb), NOT_CHECKED_UNSUPPORTED (the bytes are not audio PyAV can decode, or carry no audio stream), NOT_CHECKED_TOO_LONG (longer than maxMinutesPerFile), NOT_CHECKED_TIME (the run was out of time), NOT_CHECKED_LIMIT (cut by maxFiles), NOT_CHECKED_DUPLICATE, NOT_CHECKED_BILLING (the price of the run could not be read, so nothing was delivered and nothing was charged), NOT_CHECKED_CAP (the spending cap was reached) and NOT_CHECKED_ERROR (the dataset refused the row or the model failed). Only rows with status TRANSCRIBED are charged.

## `summary` (type: `string`):

Kept in the key-value store under RUN_SUMMARY-<runId>, with a plain RUN_SUMMARY copy in the same store (the default store of a run belongs to that run alone, so the copy cannot be overwritten by another run) and that plain key is what the template points at. Files: filesAsked, filesUnique, filesInvalid (not a URL), duplicateFiles, filesCutByLimit, filesTranscribed, filesCap, filesWriteError, filesModelError, filesChargeUnverified (the write raised and the dataset count could not settle whether the row landed, so it is not written twice). Audio: audioMinutes is the summed length of the files actually transcribed, so the buyer can compare it with the price. Money: rowsDelivered (every row written, free ones included), chargedEvents (what the platform really charged), deliveredUncharged, billingActive and billingReason, stopReason (null, spending-cap, charge-error, dataset-write-error, deadline, transcription-error or empty-input), chargeErrors with the rows whose write or charge failed and the error text. Settings actually applied: model, threads, languageRequested, maxMinutesPerFile, maxFileMb, maxFiles, vadFilter, includeSegments, includeSubtitles. datasetItemCount is our own count of written rows, datasetItemCountApi the same number as the platform reported, datasetItemCountNote says when the platform number was missing or behind. counterMismatch appears if the statuses do not add up to filesAsked, moneyMismatch if transcribed rows do not equal charged plus uncharged. durationSecs and versions (apify, httpx, faster-whisper, ctranslate2, av) close the picture.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "audioUrls": [
        "https://raw.githubusercontent.com/openai/whisper/main/tests/jfk.flac",
        "https://raw.githubusercontent.com/ggerganov/whisper.cpp/master/samples/jfk.wav"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("stas_k/speech-to-text-transcription").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "audioUrls": [
        "https://raw.githubusercontent.com/openai/whisper/main/tests/jfk.flac",
        "https://raw.githubusercontent.com/ggerganov/whisper.cpp/master/samples/jfk.wav",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("stas_k/speech-to-text-transcription").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "audioUrls": [
    "https://raw.githubusercontent.com/openai/whisper/main/tests/jfk.flac",
    "https://raw.githubusercontent.com/ggerganov/whisper.cpp/master/samples/jfk.wav"
  ]
}' |
apify call stas_k/speech-to-text-transcription --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,stas_k/speech-to-text-transcription"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/at5lG1pKYhQMsWGh6/builds/AhDNdmlnwVjySRQ5i/openapi.json
