Generating one line of speech is a solved API call. Turning a multi-speaker script into one continuous audio track is an assembly problem, and almost none of the difficulty is in the generation step.
The shape of the problem
You have a script: several characters, dozens of lines, interleaved. You want one audio file that sounds like a scene rather than a sequence of unrelated clips.
The naive pipeline is obvious and wrong:
for line in script:
audio += tts(line.text, voice=line.speaker)
It produces something technically correct and unlistenable. Here is what it misses.
1. Silence is content, not padding
Concatenated clips butt directly against each other. Real dialogue has gaps, and the gap length is meaningful: a quick reply reads as agreement, a long pause reads as hesitation or weight.
Uniform gaps are nearly as bad as none - they produce a metronomic quality that is immediately recognisable as machine-assembled. Gap duration needs to vary with what the line is doing: answering, interrupting, changing subject.
2. Level mismatch between voices
Different voice models output at different perceived loudness. Concatenate them and the listener rides the volume control.
This needs a normalisation pass across the assembled track rather than per clip, because per-clip normalisation flattens the intentional dynamics within a line.
3. Every clip carries its own edges
Generated audio often has small artefacts at the start and end - a click, a breath-like onset, a trailing fade. Individually inaudible; across two hundred joins, it becomes a texture.
Trimming leading and trailing silence to a consistent threshold, then applying a short crossfade at each join, removes most of it.
4. Regeneration must be line-scoped
This is the one that decides whether the tool is usable. Someone will change line 47 of 200.
If your pipeline regenerates the whole track, you pay full cost and - worse - every other line may come back subtly different, so a one-word fix alters the entire production. Caching per line, keyed on text plus voice plus settings, makes an edit cost one line.
cache_key = hash(line.text, line.voice_id, line.settings)
That single decision is the difference between a demo and something anyone will finish a project in.
5. Speaker assignment is a parsing problem
Scripts arrive in inconsistent formats - NAME: prefixes, dashes, stage directions in brackets, inconsistent capitalisation. Stage directions must not be read aloud, which means distinguishing performance notes from dialogue reliably enough that a missed one does not end up spoken by a character.
A better pipeline
parse script -> [{speaker, text, directions}]
resolve voices -> speaker -> voice_id
generate (cached) -> per-line audio
trim -> consistent edges
normalise -> across the whole track
space -> context-aware gaps
join -> short crossfades
export -> one track
Only step three touches a model. Everything else is ordinary audio engineering, and it is where the perceived quality actually comes from.
What this unlocks
Done properly, a category of project that previously needed a cast becomes a single-person afternoon: audio drama, fiction podcasts, dialogue-based language practice, multi-character audiobooks, two-host explainers that are actually scripted.
The constraint that remains is performance, not production. Timing-dependent delivery and overlapping speech are still beyond this, and a scene that depends on an interruption landing precisely is still better recorded by people.
This is the pipeline behind the Story Builder in Fish Audio, which compiles multi-speaker scripts into a single track on iOS. If you have found a principled way to derive gap length from dialogue context rather than heuristics, I would like to read it.
Top comments (0)