Skip to main content

Overview

GnaniSTTBatchClient wraps the whole Batch STT API — create a job, start it, poll until it finishes, then download each transcript — so you do not hand-roll multipart uploads, polling loops, or presigned-URL downloads.
Batch support needs gnani-vachana 0.8.1 or later. Earlier 0.8.0 does not retry rate-limited requests, so transcribe() can fail right after submitting a job.
For short clips (under about 60 seconds) use REST. For live audio use the realtime client.

Quick start

transcribe() creates the job, starts it, waits for it to finish, and returns the files with their transcripts. A progress bar is shown if tqdm is installed; otherwise a log line is printed each time progress changes.

What you can pass as files

files accepts any of these, alone or in a list. Local files and URLs cannot be mixed in one job. The SDK checks your input before uploading anything, so a mistake fails in milliseconds instead of after a long upload:
Only the file’s base name is sent to the server, never its path. This matters: a multipart filename containing ../ is blocked at the network edge with a 403 HTML page that never reaches Gnani’s logs. With the SDK, open("../audio/call.wav") is safe.
Files larger than 10 MB are not supported by the SDK yet. Split long recordings, or pass public URLs.

Options

transcribe() takes files and language_code, plus every option below. create_job() takes the same options.
The SDK raises ValueError before any network call for an unsupported language code, speakers outside 1–8, a bias_score that is not one of the listed values, or more than 100 bias_words.

Step by step

Use create_job() when a job is long-running, when you want to keep its ID, or when another process will collect the results.

Resume a job later

A job keeps running on Gnani’s servers whether or not your program is. Re-attach with its ID:

Create now, start later

List and cancel jobs

list_jobs() follows pagination for you.

Results

BatchJob

BatchFile

text, segments, and transcript download the transcript the first time you read them. Transcript links expire after one hour; if one has expired the SDK fetches a fresh link and retries once, so you never handle that yourself. Reading them on a file that is not COMPLETED raises ValueError with the file’s status and error.

BatchResult

What transcribe() returns. Iterate it, index it, or use: save() names each file after its audio (call1.wav becomes call1.json). Two files with the same name get _2, _3, and so on. Failed files are skipped.

Waiting for a job

wait() polls the job until it reaches a terminal status.
Pressing Ctrl-C while waiting stops your program but not the job. The job ID is logged so you can resume with get_job().

Handling failures

A job that finishes is not always a job that succeeded. wait() and transcribe() treat the final status like this:
Pass raise_on_failure=False to get the job back for any final status instead of an exception.

Other errors

Rate limits

The API limits how fast one key can make requests. Rate-limited requests (429) are retried automatically, up to 5 times, waiting for the server’s Retry-After if it sends one and otherwise 1, 2, 4, 8, then 16 seconds. Status and file reads are also retried on 502, 503, and 504. If every retry is refused, APIError is raised.

Async

AsyncGnaniSTTBatchClient has the same methods and options. Calls run on worker threads, so they never block your event loop and no extra dependency is needed.
Differences from the sync client: transcribe() downloads transcripts for up to eight files at a time, so a 100-file job finishes quickly. Cancelling the task that is awaiting wait() leaves the job running on the server.

Webhooks

Pass callback_url to be notified when the job reaches a terminal state, instead of (or as well as) waiting:
Webhooks are best-effort — see Webhooks for the payload and events. Polling with wait() or get_job() remains the source of truth.

Supported languages

Batch supports the same ten languages as the REST client:
en-IN, hi-IN, bn-IN, gu-IN, kn-IN, ml-IN, mr-IN, pa-IN, ta-IN, te-IN. Pass "auto" to identify the language among all of them, or a comma-separated list to restrict identification to the languages you expect.

Batch STT API

The HTTP endpoints, statuses, limits, and webhook payloads behind the SDK.

REST and realtime STT

Short clips and live audio with the same package.