Word-Level Timestamps
Set timestamp_granularity on the REST or Batch speech-to-text API to get start and end times for your transcript. The value you pick decides which field the response adds:
Both fields are lists of {text, start, end} objects. word returns words and segment returns segments, each on its own. The older timestamps object appears only when you also set with_timestamps=true.
Use word timestamps for word-by-word caption highlighting, karaoke-style playback, cutting audio at an exact word, or lining up a transcript with video. Use segment timestamps to find roughly where each part of a long Batch recording is.
timestamp_granularity is available in the Python SDK from sarvamai 0.1.50 and in the JavaScript SDK from sarvamai 1.1.23. Upgrade with pip install -U sarvamai or npm install sarvamai@latest.
REST API
Word response
words has one entry per word of the transcript, in the same order, so you can map each word back to its place in transcript.
If a word couldn’t be timed, it keeps its text but its start and end are null. The other words keep their times:
Skip or fill in only the untimed entries:
Segment response
With timestamp_granularity=segment, the response has a segments list instead of words. Each entry is one chunk of audio as the model processed it, so a segment can hold several sentences, and its start and end include any silence in that chunk. A REST request usually returns a single segment that covers the whole clip, from 0.0 to the end of the audio, even if the speaker pauses:
Batch API
For recordings longer than 30 seconds, set timestamp_granularity in job_parameters. Each output file has the same words or segments field as the REST response. Times are measured from the start of that file, so you can use them directly even though long audio is processed in chunks. With segment, you get one entry per chunk; chunks are split at pauses in the speech.
Batch output files always include a timestamps key. It is null unless you also set with_timestamps=true, so check for words or segments rather than for timestamps.
After creating the job, upload the audio, start the job, and download the output with the standard Batch API workflow.
You can combine timestamp_granularity with with_diarization. Speaker labels are in diarized_transcript.entries, so to see who said a word, match the word’s time against each entry’s start_time_seconds and end_time_seconds.
Errors
The API checks timestamp_granularity when the request arrives. If the model or mode can’t return the timestamps you asked for, it returns a 400 with a message that names the supported options:
For Batch jobs, these checks run when you create the job, so an unsupported combination fails before you upload any audio.
The older with_timestamps format
Before timestamp_granularity, timestamps came from with_timestamps=true. It still works and returns the same timestamps object as before: three parallel lists, where timestamps.words[i] runs from timestamps.start_time_seconds[i] to timestamps.end_time_seconds[i].
Despite its name, timestamps.words holds chunks of the transcript, not single words. It carries the same information as segments, in the older format.
with_timestamps will be deprecated soon. New integrations should use timestamp_granularity. Existing integrations keep working for now, but plan to move.
To switch an existing integration:
- For the same segment-level output, replace
with_timestamps=truewithtimestamp_granularity=segmentand readsegmentsinstead oftimestamps. - For one entry per word, use
timestamp_granularity=wordwithmodel="saaras:v4"and readwords.
segments[i].text, .start, and .end hold the same values as timestamps.words[i], timestamps.start_time_seconds[i], and timestamps.end_time_seconds[i].
If you send both with_timestamps=true and timestamp_granularity, the response includes both the timestamps object and the words or segments field, so you can migrate one reader at a time.