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).

Transcribe again with other options

A finished job can be transcribed again from the audio Scriptivox still holds, with another language or speaker labels: no upload, no download. It is a new job, charged like any other. The options are this call's own (omit language and it is detected again).

from scriptivox import SourceExpiredError

try:
    again = client.transcribe_again(job["id"], language="es", diarize=True)
    done = client.wait(again["id"])
except SourceExpiredError:
    pass  # the audio is kept 24 hours after a job ends: send the file again with transcribe(file=...) or url=

Waiting

wait(id) polls until the job ends. It waits 2 s between polls at first, growing to 10 s, and longer when a check of an unfinished job answers with a longer Retry-After (up to 60 s). It also 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 (see Maintenance), 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.

Maintenance

Now and then part of the API is paused for maintenance. A paused request answers 503 MAINTENANCE and the SDK raises MaintenanceError: nothing was created or charged, so send the same request again later. Jobs already accepted always finish.

from scriptivox import MaintenanceError

try:
    client.transcribe(file="meeting.mp3")
except MaintenanceError as e:
    print(e.message)      # what is paused, with our message
    print(e.scope)        # "upload", "link" or "global"
    print(e.back_by)      # when we expect it back (ISO 8601, UTC), or None
    print(e.retry_after)  # seconds to wait before sending it again
    print(e.status_url)   # the status call below

status() says whether the API is taking new jobs, before you send any. It needs no API key (the call is limited per IP):

import scriptivox

s = scriptivox.status()  # or client.status(); await scriptivox.async_status() in asyncio
if s["accepting_new_jobs"] is False:
    for p in s["maintenance"]["paused"]:
        print(p["name"], p["message"] or "", p["back_by"] or "")
    print("Try again in", s["maintenance"]["retry_after_seconds"], "seconds")
elif s["status"] == "unknown":
    print("Could not check just now")  # not the same as "down"
  • status is operational, maintenance or unknown. unknown means the state could not be checked just now, not that the API is down; the fields that could not be checked are then None.
  • Scope link: only links to video and social media sites are paused on transcribe(). Uploads and other file links carry on, so accepting_new_jobs stays True.
  • Full maintenance (a few minutes, for example during a planned upgrade) pauses every call, reads included: scope global and an empty still_working. wait() waits it out and carries on polling.
  • If the status call itself gets no answer, status() raises APIConnectionError. It never reports "all fine" from a failed call.
  • Uptime and incident history: status.scriptivox.com.

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. A maintenance pause usually asks for 5 minutes or more, so its MaintenanceError is raised for you to handle (see Maintenance).
  • 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.6.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.6.0
File Size Uploaded Provenance Actions
scriptivox-0.6.0.tar.gz 140.2 kB Without provenance Details for scriptivox-0.6.0.tar.gz

Built distribution (wheel)

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

Total release size: 187.3 kB

Release files / scriptivox-0.6.0.tar.gz

Download URL scriptivox-0.6.0.tar.gz
Size 140.2 kB
Tags Source
SHA-256 checksum
How to use checksums
7a922b84769e0643f84bfadab7a841df9a07e92a2814a88f6d1b6ef05a5a3c38
BLAKE2b-256 checksum
How to use checksums
195f394a46e5b273f7588f2ffa26f464dc0c8f337862cd6288496180b46802dd
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.6.0-py3-none-any.whl

Download URL scriptivox-0.6.0-py3-none-any.whl
Size 47.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e868b1bd81b010454488b71d725e9a1b08ceb6b260d0340f80e31235b2ff2ece
BLAKE2b-256 checksum
How to use checksums
39f0203363681669126f1d88bf8bfe79b6fe00dbc5303a1dc542b90a24a9ddb2
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.6.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