Inspect transcript words without start or end: skip them in cuts
Inspect transcript words can omit start or end. Treat an untimed word as unknown, and never cut across a gap that contains one: 0 of its time is safe to remove.

The inspect transcript returns words[], and start and end are optional in the schema. A pause cutter that does w["end"] on every word will raise a KeyError on an untimed one, or worse, treat a missing time as 0 and cut a minute of speech. Skip untimed words when you compute gaps, but treat an untimed word as a barrier: do not remove any gap beside it.
Whether untimed words occur in practice for your audio is not stated in the docs; the code below is defensive.
Rules
- A gap exists only between two timed words that are adjacent in the list.
- If an untimed word sits between two timed ones, the gap is unknown: keep it.
- Never default a missing
startorendto 0. - Log how many words you skipped so a bad transcript is visible.
Effect on the cut list
Hypothetical transcript of six words with one untimed word at index 3.
| Between words | Gap | Decision at 0.35 s |
|---|---|---|
| 1 and 2 | 0.80 s | cut |
| 2 and 3 | 0.10 s | keep |
| 3 and untimed 4 | unknown | keep |
| untimed 4 and 5 | unknown | keep |
| 5 and 6 | 0.60 s | cut |
Python
def gaps(words, threshold=0.35):
cuts, prev = [], None
for w in words:
s, e = w.get("start"), w.get("end")
if s is None or e is None:
prev = None # barrier: gap beside it is unknown
continue
if prev is not None and s - prev > threshold:
cuts.append((round(prev, 3), round(s, 3)))
prev = e
return cutsNotes
- A skipped word still costs nothing extra; the STT price is per audio minute ($0.01).
- If many words are untimed, cut with sentence
segments[]instead: they have no gaps by construction. - Trim rejects an output under 0.2 s, so still drop slivers.
Sources
Related posts
More in Developers
- IVR phone menu prompts with TTS: 8 kHz mu-law WAV and cost per prompt
Make phone-menu prompts as 8 kHz mu-law or A-law WAV with Sume TTS. A 20-prompt menu bills 20 cents because each short job hits the 1-cent minimum.
- Sume job webhook retries: 370 s worst case, then poll or redeliver
Sume retries a job webhook 10 times, 30 s apart, with a 10 s timeout each: 270 s of gaps and up to 370 s in total. What to do when the window closes.
- jobs_wait any on 20 Wan 3.0 clips: the other 19 still bill $5.94
With wait_for any, jobs_wait returns when one of 20 Wan 3.0 480p 5-second clips ends, but the other 19 keep running and billing: $5.9375 of $6.25.
- Kling Motion Control: a 30 s job reserves $4.73, refunded on failure
Sume reserves ceil(seconds) x $0.1575 for Kling 3.0 Motion Control: $4.725 for 30 s, shown as 473 cents. Failed or pre-generation canceled jobs are refunded.
Written by Sume