What IndexTTS 2 can and cannot guarantee about timing through SmarToken
- Set an in-point and out-point for each narration segment.
- Generate the speech, then measure the returned WAV file.
- If it runs long, shorten the script and generate it again. Adjust pauses or the picture in the editor when appropriate.
- Listen to the final edit. Frame-accurate or lip synchronization needs further adjustment.
Basic workflow: generate, measure, and compare a voiceover to your video cut
Mark the narration in- and out-points, then draft the line for that window. Submit model, text and reference voice as documented; use the returned task ID to retrieve the completed audio.[1] Save the WAV and measure it against the timeline.
import wave
from pathlib import Path
def get_wav_duration_seconds(path: str) -> float:
"""Return duration of a PCM WAV file in seconds.
Assumes standard uncompressed WAV input. Multi-channel audio
(e.g., stereo) is supported because duration depends on frame
count, not channel count.
"""
wav_path = Path(path)
with wave.open(str(wav_path), "rb") as wf:
n_frames = wf.getnframes() # total number of audio frames [2]
frame_rate = wf.getframerate() # sampling frequency (frames per second) [2]
if frame_rate == 0:
raise ValueError("Frame rate is zero; cannot compute duration.")
return n_frames / frame_rate
if __name__ == "__main__":
audio_file = "voiceover_segment.wav" # path to IndexTTS 2 output
duration = get_wav_duration_seconds(audio_file)
print(f"Duration: {duration:.2f} seconds")
# Basic note: if your TTS output is not WAV (e.g., MP3),
# convert it to a standard PCM WAV before using this helper.Compare the measured duration with the available window. If speech runs long, revise the text or edit at a natural pause; if short, retain an intentional pause or adjust the script. A matching total duration alone does not guarantee word or lip synchronization.
Fixing overdrawing or underfilling a video cut
- Long take: trim a natural pause or shorten redundant words while preserving meaning.
- Short take: keep a deliberate pause or add a useful phrase, then generate a new take.
- After each change, remeasure the exported audio and listen across the cut.
For a large mismatch, rewriting and regenerating usually sounds more natural than cutting through words.
Using documented SmarToken parameters without chasing research-only timing features
Submit the three fields shown above with an Idempotency-Key, then use the returned task ID to retrieve the audio.[1] The current request body has no target-duration, speed or stability field. The token-count control discussed in the research paper is a model capability, not a field in this endpoint.[4]
Send an Idempotency-Key and retain the task ID. For a retry of the same request with the same account and API key, reuse that key; changing the text or reference audio under it produces a conflict. If you have a task ID, check the original task first. If submission timed out before an ID arrived, retry the same request with the same account, API key and idempotency key to recover the task. Use a new key only when you intend a separate generation.
Managing pacing and duration for long scripts by segmenting your project
- Map each scene to a narration window and generate one audio segment at a time.
- Measure each take, adjust where needed, then place the segments in order.
Listen across transitions for abrupt changes in pauses, voice or energy; adjust the edit where needed.
Adjust timing after generation
When a segment does not fit, first revise the words and regenerate it. You can also trim silence or adjust timing in your editor. If you change playback speed, listen for unnatural pronunciation and remeasure the final export. The SmarToken request does not expose speed or stability settings for this model.
- Change one thing at a time and compare the result with the original.
- Keep the delivery intelligible and check the final duration against the video cut.
Testing timing reliability across multiple IndexTTS 2 takes
This script measures existing PCM WAV files; it does not call a model. Save it as measure.py and run python3 measure.py 8 take1.wav take2.wav take3.wav, where 8 is the target in seconds. Keep each text and take identified; the maximum in a sample does not guarantee a future take will fit.
import statistics
import sys
import wave
from pathlib import Path
if len(sys.argv) < 3:
sys.exit('Usage: python3 measure.py TARGET_SECONDS take1.wav [take2.wav ...]')
target = float(sys.argv[1])
if target <= 0:
sys.exit('TARGET_SECONDS must be positive')
durations = []
for name in sys.argv[2:]:
with wave.open(str(Path(name)), 'rb') as audio:
seconds = audio.getnframes() / audio.getframerate()
durations.append(seconds)
print(f'{name}: {seconds:.3f}s, difference {seconds - target:+.3f}s')
print(f'takes={len(durations)}, mean={statistics.mean(durations):.3f}s, '
f'min={min(durations):.3f}s, max={max(durations):.3f}s')Measured duration of three generated takes
On December 1, 2026, we generated each English line below once with IndexTTS 2 on SmarToken, using the same publicly available synthetic reference voice. Duration is WAV frame count divided by sample rate.
| English script | Words | Duration (seconds) | WAV sample frames |
|---|---|---|---|
| Add water slowly. | 3 | 1.87 | 41,216 |
| Add water slowly, then wait thirty seconds before pouring again. | 10 | 3.89 | 85,760 |
| Add water slowly, then wait thirty seconds before pouring again. Keep the kettle steady, watch the scale, and stop when it reaches one hundred and fifty grams. | 27 | 8.78 | 193,536 |
The takes measured 1.87, 3.89, and 8.78 seconds. These are single runs of three different scripts, not repeated samples of the same line; they do not guarantee duration for another script or another run. Listen to the linked audio below; the takes have not been manually reviewed for pronunciation and completeness.
All three outputs are 22,050 Hz, mono, 16-bit PCM WAV. Against an illustrative 8-second video cut, the takes are 6.13 seconds short, 4.11 seconds short, and 0.78 seconds long, respectively. Eight seconds is a comparison target, not a duration sent in the generation request.
Additional automatic check: we converted the three WAV files to 16 kHz mono and transcribed them locally with whisper.cpp 1.9.2 and tiny.en-q5_1. The lines below are the recognizer’s output, with numbers rendered as digits. The model checksum is listed in the source.[6] The recognized 30 seconds and 150 grams match the scripts, but ASR can miss or hallucinate words; this does not replace listening and human review.
1. Add water, slowly.
2. Add water slowly, then wait 30 seconds before pouring again.
3. Add water slowly, then wait 30 seconds before pouring again. Keep the kettle steady, watch the scale and stop when it reaches 150 grams.