Skip to content
C.W.K.
Stream
Lesson 04 of 05 · published

One Language per Call, Enforced by the Build

~12 min · tts, constraints, hard-checks, provider-behavior

Level 0Cold Workshop
0 XP0/35 lessons0/12 achievements
0/100 XP to next level100 XP to go0% complete

A Provider Behavior That Reshapes the Pipeline

The narration is bilingual by design — one language carries the argument, the other carries the relationship. That is an editorial decision, and it collides immediately with a technical fact about speech synthesis: put two languages in one request and the foreign words come back mispronounced a fraction of the time. Not always. Not never. Unpredictably, because the models are trained on mixed text in a way that makes the reading a gamble.

Unpredictable is the worst of the three options. Always-wrong you would work around; never-wrong needs no handling. A failure that appears in maybe one take out of several means you cannot trust any take without listening, and you cannot fix it by re-requesting because the same request may come back fine and then break later.

The Fix Is Structural, Not Careful

The response was to change what the unit of synthesis is. The atom is not a sentence and not a beat — it is a language-uniform run. Every request contains exactly one script, so the situation that produces the gamble simply cannot arise.

Then the rule is enforced rather than remembered: a build check fails any segment carrying both scripts, digits and punctuation excepted. That is the part worth copying. A rule that lives in someone's head is a rule that survives until the day somebody is in a hurry, and this one would fail silently and intermittently — the worst possible combination for a rule enforced by discipline.

Never Splice a Single Foreign Word

The obvious workaround is to synthesize the odd foreign word separately and splice it in. That was considered and rejected, because a one-word insert into a line does not sound like a quotation — it sounds like a hiccup. The gap that reads as breath around a whole quoted sentence reads as a glitch around a single word.

So the rule is to not create the situation: a run in one language transliterates any foreign term into its own script. If a line genuinely needs the foreign term in its original form, then the line itself is in that language. The switch happens at a meaning boundary or it does not happen.

Intermittent failures must be made structurally impossible, not carefully avoided. A defect that appears sometimes defeats both testing and discipline: the test passes, the reviewer hears a good take, and the failure ships later. When you find one, the useful move is almost always to change the shape of the operation so the failing case cannot be constructed — not to add vigilance.

Code

The check that makes the rule unforgettable·python
HANGUL = re.compile(r"[\uac00-\ud7a3]")
LATIN  = re.compile(r"[A-Za-z]")

def check_segment_language_purity(segments: list[Segment]) -> list[str]:
    """A segment carrying two scripts is a build failure.

    Digits and punctuation are exempt - they are read the same way
    by either voice, so they do not trigger the mispronunciation.
    """
    errors = []
    for seg in segments:
        has_hangul = bool(HANGUL.search(seg.text))
        has_latin = bool(LATIN.search(seg.text))
        if has_hangul and has_latin:
            errors.append(
                f"{seg.key}: mixed script in one synthesis call -"
                f" split at the meaning boundary or transliterate."
                f"  text={seg.text!r}"
            )
    return errors


# Note what this is NOT: a warning, a lint suggestion, a note in
# the style guide. It fails the build, because the defect it
# prevents is intermittent and would otherwise ship.
Three ways to handle a foreign term, ranked·text
BAD    one request, both scripts
       "그 사람이 pipeline 이라고 불렀어"
       -> pronunciation is a dice roll on every synthesis

WORSE  splice a one-word foreign call into the line
       [ko run] + [1-word en call] + [ko run]
       -> the gap reads as a hiccup, not a quotation

GOOD   transliterate into the run's own script
       "그 사람이 파이프라인이라고 불렀어"
       -> one script, one call, no gamble

ALSO GOOD   if the term must stay in its original form,
            the whole line is in that language, and the
            switch happens at a meaning boundary.

External links

Exercise

Find an intermittent failure in your own systems — something that fails a small fraction of the time and gets handled with a retry, a warning, or a note telling people to be careful. Ask what shape change would make the failing case impossible to construct rather than unlikely. Then estimate the cost of that change against the ongoing cost of the vigilance it replaces.
Hint
Retry logic is the usual sign that a shape problem is being managed rather than solved. A retry converts an intermittent failure into a slower success most of the time, which is genuinely useful and also removes the pressure that would have led someone to fix the underlying shape.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.