Skip to main content

Scriptivox Python SDK

The official Python client for the Scriptivox transcription API. Upload a file or pass a link, wait for the transcript, export SRT, VTT or text, list your jobs and verify webhooks. Sync and asyncio clients, typed responses and one exception class per error code.

  • Python 3.9 or newer. One dependency: httpx.
  • Every submit carries an Idempotency-Key, so a retried call never starts a second job.
  • Large files are streamed from disk, never read into memory.

Install

pip install scriptivox

Quickstart

Create an API key on the API Keys page and add balance on the Billing page.

from scriptivox import Scriptivox

client = Scriptivox()  # reads SCRIPTIVOX_API_KEY, or pass api_key="sk_live_..."

job = client.transcribe(file="meeting.mp3", language="en")
done = client.wait(job["id"])
print(done["result"]["full_transcript"])

From a public link (direct file links, Google Drive, Dropbox and OneDrive share links, and public TikTok, Instagram, Facebook, X and Snapchat posts):

job = client.transcribe(url="https://example.com/podcast.mp3", diarize=True, speaker_count=2)
reel = client.transcribe(url="https://www.instagram.com/reel/C0nT3stR33l/")

A social post is checked when you send it, so that call takes a few seconds. A post that is private, deleted or has no video raises UrlNotAccessibleError at once (e.error.get("reason") says why, e.error.get("platform") names the site), and nothing is created or charged.

Pass language when you know it: it is faster and more accurate than auto-detection. Omit it to auto-detect.

Captions and plain text

srt = client.get(job["id"], format="srt", max_words=4)
vtt = client.get(job["id"], format="vtt", include_speakers=True)
text = client.get(job["id"], format="text", include_timestamps=True)

format="json" (the default) returns the whole job. The caption options are max_words, max_chars, max_duration, sentence_aware, include_speakers, strip_chars and, for text, include_timestamps. See caption export.

Upload with progress

def show(p):
    print(f"{p.percent:5.1f}%  {p.loaded}/{p.total} bytes")

upload = client.upload("lecture.mp4", on_progress=show)
job = client.transcribe(upload_id=upload["upload_id"])
# or in one call:
job = client.transcribe(file="lecture.mp4", on_upload_progress=show)

file can be a path, bytes, or a binary file object (open(path, "rb")). For bytes or a stream without a name, pass filename="audio.mp3". A non-seekable stream also needs size=. Filenames are made ASCII-safe for you (Réunion.mp3 is sent as Reunion.mp3).

Waiting

wait(id) polls until the job ends. It waits 2 s between polls at first, growing to 10 s, and honours Retry-After when rate-limited. It returns the completed job. A job that fails raises TranscriptionFailedError, whose code is the job's error.code:

from scriptivox import TranscriptionFailedError

try:
    done = client.wait(job["id"], timeout=3600)
except TranscriptionFailedError as e:
    print(e.code, e.transcription["error"]["message"])  # e.g. URL_NOT_ACCESSIBLE

Failed and cancelled jobs cost nothing. Prefer webhooks to polling for long files.

Listing, cancelling, deleting, balance

for t in client.list(status="completed"):      # follows the cursor page by page
    print(t["id"], t["audio_duration_seconds"])

client.cancel(job_id)    # before transcription starts; not charged
client.delete(job_id)    # a finished job and its transcript
b = client.balance()
print(b["available_cents"], b["auto_topup"]["enabled"])

list() takes status, from_, to (datetime or ISO string), limit (page size) and order. Items leave out result; get(id) has it.

Webhooks

Pass webhook_url when you submit, and check every request with verify_webhook. It needs the raw body, your key's webhook signing secret (whsec_…, on the API Keys page) and the request headers. It refuses a bad signature and a timestamp more than 5 minutes old.

import os
from fastapi import FastAPI, Request, Response
from scriptivox import verify_webhook, WebhookVerificationError

app = FastAPI()

@app.post("/scriptivox")
async def scriptivox_webhook(request: Request):
    try:
        event = verify_webhook(await request.body(), request.headers, os.environ["SCRIPTIVOX_WEBHOOK_SECRET"])
    except WebhookVerificationError:
        return Response(status_code=400)
    delivery_id = request.headers["x-scriptivox-delivery"]  # the same on every retry: skip ones you have handled
    if event["event"] == "transcription.completed":
        print(event["transcription_id"], event["result"]["full_transcript"][:80])
    elif event["event"] == "transcription.failed":
        print(event["transcription_id"], event["error"]["code"])
    return Response(status_code=200)

Flask: verify_webhook(request.get_data(), request.headers, secret). Django: verify_webhook(request.body, request.headers, secret).

client.test_webhook("https://your.server/scriptivox") sends a signed webhook.test event and tells you what your server answered. client.resend_webhook(job_id) sends a finished job's final event again.

Errors

Every error extends ScriptivoxError. When the API answers with an error you get an APIError subclass named after its error.code, under a class for its HTTP status:

from scriptivox import APIError, PaymentRequiredError, RateLimitExceededError, ZeroBalanceError

try:
    client.transcribe(url="https://example.com/a.mp3")
except ZeroBalanceError:
    print("Add funds on the Billing page")
except RateLimitExceededError as e:
    print("Too many jobs in progress:", e.error.get("in_flight"), "of", e.error.get("limit"))
except APIError as e:
    print(e.status, e.code, e.message, e.request_id)  # quote request_id to support
Class When
BadRequestError (400): InvalidRequestError, InvalidFilenameError, InvalidMediaFormatError, … The request is wrong; fix it, do not retry
AuthenticationError (401): InvalidApiKeyError, ApiKeyRevokedError The key is missing, wrong or revoked
PaymentRequiredError (402): InsufficientBalanceError, ZeroBalanceError Add balance
NotFoundError (404): TranscriptionNotFoundError, UploadNotFoundError Wrong id
ConflictError (409), IdempotencyKeyLockedError Not allowed in the job's current state
RateLimitError (429): RateLimitExceededError Too many requests, or too many jobs in progress
InternalServerError (5xx), ServiceUnavailableError (503): MaintenanceError, LinkCheckUnavailableError Our side; safe to retry after e.retry_after seconds
APIConnectionError, APITimeoutError No answer
UploadFailedError The file upload itself failed
TranscriptionFailedError wait(): the job ended failed
WaitTimeoutError wait(): still running at the timeout
WebhookVerificationError verify_webhook(): not a genuine, fresh webhook

The full list of codes is in the API reference.

Retries, timeouts and idempotency

  • Requests that are safe to repeat (reads, deletes, cancels and submits with an Idempotency-Key) are retried up to 2 times after a dropped connection or a 5xx, waiting longer before each try (0.5 s, 1 s, 2 s, …).
  • A 429 or 503 with Retry-After is retried after that many seconds, if it is 60 s or less. A 429 without Retry-After (the jobs-in-progress cap) is raised at once.
  • upload() and transcribe() send a new random Idempotency-Key per call, reused on the SDK's own retries. Pass idempotency_key= (for example your own record id) to make a retry after a crash safe too.
client = Scriptivox(max_retries=4, timeout=30.0)  # timeout per request, in seconds

asyncio

import asyncio
from scriptivox import AsyncScriptivox

async def main():
    async with AsyncScriptivox() as client:
        job = await client.transcribe(file="meeting.mp3", language="en")
        done = await client.wait(job["id"])
        async for t in client.list(status="completed"):
            print(t["id"])

asyncio.run(main())

Configuration

Setting Argument Environment variable Default
API key api_key SCRIPTIVOX_API_KEY none (required)
Base URL base_url SCRIPTIVOX_BASE_URL https://api.scriptivox.com
Retries max_retries 2
Request timeout (s) timeout 60
Your own httpx client http_client a new httpx.Client

Responses are plain dicts, typed with TypedDicts generated from the OpenAPI document (scriptivox.Transcription, scriptivox.Balance, …).

Development

python scripts/generate.py            # regenerate _types.py and _error_codes.py from openapi/openapi.json
python scripts/generate.py --fetch    # refresh the snapshot from platform.scriptivox.com first
pip install -e '.[dev]' && pytest     # unit tests, no network

# integration tests against a test deployment
SCRIPTIVOX_API_KEY=sk_live_... SCRIPTIVOX_BASE_URL=https://api-test.scriptivox.com pytest tests/test_integration.py

License

MIT

Metadata

Release files for scriptivox 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for scriptivox 0.2.0
File Size Uploaded Provenance Actions
scriptivox-0.2.0.tar.gz 121.5 kB Without provenance Details for scriptivox-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for scriptivox 0.2.0
File Interpreter ABI Platform Actions
scriptivox-0.2.0-py3-none-any.whl Python 3 none any Details for scriptivox-0.2.0-py3-none-any.whl

Total release size: 160.5 kB

Release files / scriptivox-0.2.0.tar.gz

Download URL scriptivox-0.2.0.tar.gz
Size 121.5 kB
Tags Source
SHA-256 checksum
How to use checksums
d59c0fd8df83b81e4ac04bcfd7aba8f7e135b2b2b5d7398fe9460314548b3079
BLAKE2b-256 checksum
How to use checksums
1f94d2a34f664fba3e6a81085ca34b986f62fa88dee522602be920b558d39b2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.14

Release files / scriptivox-0.2.0-py3-none-any.whl

Download URL scriptivox-0.2.0-py3-none-any.whl
Size 39.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2aff9d27e9c2824390737635fb4e66811f2dedf15b152e67485ef3ea64498d06
BLAKE2b-256 checksum
How to use checksums
5324052df028fc151f65ae96c0b280fc87160e3b254d7520d59c41566bebbc3f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.14

Security for scriptivox 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page