◉GEMINI LABJP
●2.5 ROUTE — From today, 12/1, calls to gemini-2.5-pro and 2.5-flash are rerouted to newer models automatically●CLI 0.71.1 — Gemini CLI stable is still v0.71.1, with a 0.73 nightly published on 11/30●INTRO END — Introductory pricing for 3.8, 3.7 and 3.6 Flash ends on 12/31. 30 days left●VERTEX — Developers are asking how to run Gemini CLI with Vertex AI credentials●NEON — Gemini 4 Neon became generally available on 11/18 (paid tier only)●IMAGE TEXT — A new test shows text inside an image can sway Gemini's answer●2.5 ROUTE — From today, 12/1, calls to gemini-2.5-pro and 2.5-flash are rerouted to newer models automatically●CLI 0.71.1 — Gemini CLI stable is still v0.71.1, with a 0.73 nightly published on 11/30●INTRO END — Introductory pricing for 3.8, 3.7 and 3.6 Flash ends on 12/31. 30 days left●VERTEX — Developers are asking how to run Gemini CLI with Vertex AI credentials●NEON — Gemini 4 Neon became generally available on 11/18 (paid tier only)●IMAGE TEXT — A new test shows text inside an image can sway Gemini's answer
Articles/Dev Tools
⟐ Dev Tools/2026-07-14Advanced

Making TTS seams inaudible: prosody continuity and silence boundaries for long-form narration

Splitting a long article by sentence and synthesizing each piece leaves audible seams: prosody resets at every sentence start, clicks appear at PCM joints, and pauses feel uneven. Four layers -- context priming, zero-crossing edge fades, punctuation-aware silence, and an idempotent seam ledger -- make the joins disappear, with full code.

Gemini TTSSpeech synthesisNarrationSolo development

✦ Premium Article

I was preparing the guidance voice for a calming app I run as an indie developer, using Gemini's TTS. I had synthesized it sentence by sentence, stitched the pieces together, and sat down to hear the whole thing for the first time. And I stopped.

At every boundary between sentences, the speaker seemed to swap for a person for an instant. Each individual clip sounded clean, yet the moment they were joined the result felt restless. A voice meant to ease someone toward sleep tensed up, faintly, at each seam.

There was not one cause but three. A reset in intonation, a small click at each PCM joint, and uneven pauses. Together they produced a recording that announced its own seams. This article separates those three, and gives working code for each. Not merely splitting and joining -- taking it all the way to where the ear stops noticing the joins.

Why seams catch the ear

You cannot voice a long article in a single request. There is a ceiling on how much one call can synthesize, and a few thousand characters will cut off partway. So you split by sentence. That much is unavoidable.

The problem is what happens when you join the pieces back. In my own runs, the discontinuity came in three flavors, each with a different character.

Seam symptomWhat you hearLayer that fixes it
Prosody resetA stiffness, as if re-reading from the top at each sentenceContext priming
Boundary clickA brief pop at the joinZero-crossing snap and edge fade
Uneven pausesSentences collide, or dragPunctuation-aware silence

Naive "split by sentence, insert a fixed pause, concatenate raw PCM" leaves the reset and the click intact. A constant pause length keeps the pacing uneven. From here, we peel the problem apart one layer at a time.

Passing the previous ending into the next call (context priming)

The most obvious offender is intonation snapping back to blank at each sentence start. The model has no idea how the previous sentence ended; each request arrives as a fresh introduction.

So we hand it a short tail of the prior sentence and ask it to continue in the same manner. Only the current sentence is spoken. The previous one is nothing more than a cue for carrying the cadence forward.

from google import genai
from google.genai import types
 
client = genai.Client()
MODEL = "gemini-3.1-flash-tts-preview"
VOICE = "Kore"
STYLE = "Read in a calm, low voice at a steady, unhurried pace."
 
def build_prompt(text: str, prev_tail: str) -> str:
    if prev_tail:
        return (
            f"{STYLE}\n"
            f"You just finished reading: \"{prev_tail}\". Keep the same timbre and the flow of intonation.\n"
            f"Now read only the following sentence:\n{text}"
        )
    return f"{STYLE}\nRead the following sentence:\n{text}"
 
def synth(text: str, prev_tail: str = "") -> bytes:
    resp = client.models.generate_content(
        model=MODEL,
        contents=build_prompt(text, prev_tail),
        config=types.GenerateContentConfig(
            response_modalities=["AUDIO"],
            speech_config=types.SpeechConfig(
                voice_config=types.VoiceConfig(
                    prebuilt_voice_config=types.PrebuiltVoiceConfig(voice_name=VOICE)
                )
            ),
        ),
    )
    cand = resp.candidates[0]
    if cand.finish_reason and cand.finish_reason.name != "STOP":
        raise RuntimeError(f"unexpected finish_reason: {cand.finish_reason.name}")
    return cand.content.parts[0].inline_data.data  # 24kHz 16bit mono PCM

It does not line up perfectly. Priming is a nudge, not a guarantee. Even so, the stiffness at sentence starts visibly dropped in my runs. I keep the tail to around 20 to 24 characters. Hand over more and the model will occasionally read the cue itself. Keep the cue short -- just enough to convey the flow.

✦

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
✦Separate the three distinct causes of seams at sentence boundaries and take away code that addresses each one
✦Context priming carries the previous sentence's cadence into the next call, while zero-crossing edge fades remove the click at the join
✦Take home an idempotent seam ledger -- JSON schema and regeneration code -- so re-rendering one chunk never rebuilds the whole track
Secure payment via Stripe · Cancel anytime
✦

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Gemini Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • ✦Copy-paste ready implementation code
  • ✦New advanced guides published daily
  • ✦$5/mo or $10 for lifetime access
View Membership →

Related Articles

⟐ Dev Tools2026-11-07
The Morning an Android Build Stopped on 'Duplicate Resources' and Dropbox Was the Cause
Building inside a synced folder left more than 80 conflicted copies in my generated files and stopped an Android build. Here is how I found the cause, how I took build and .gradle out of sync, and where I now keep a project before letting an agent run builds.
⟐ Dev Tools2026-10-29
The Nightly Batch Sat Stalled Until Morning — Splitting Retryable Failures by gemini-api Exit Code
The gemini-api CLI, in beta since 10/27, exits with 0, 1, 2 or 3. Which to retry, which should stop a nightly batch, and the double-billing trap when a background job is rerun. Includes a bash wrapper.
⟐ Dev Tools2026-10-29
Before You Install gemini-api: It Is Not Gemini CLI, and Where I Decided It Belongs
The Gemini API CLI (gemini-api, beta) that appeared on 10/27 is not a successor to Gemini CLI. Here is where I placed it after reading the README, what to check with --dry-run before any billing, and how to pin it in CI.