Saturday, July 18, 2026

Decoding Thai Phonology for AI: Teaching Text-to-Speech Models Through the Lens of Traditional Bases and Tone Classes 4

 The Ghost in the Script: Handling Unwritten Vowels and Silent Tokens for TTS Tokenization

How to handle Thai unwritten vowels, vowel mutation, and Pāli exceptions in Text-to-Speech (TTS) pipelines and G2P tokenization.





In Western languages, what you see is largely what you get; spacing is predictable, and vowels are explicitly mapped on the screen. In Thai, however, a Text-to-Speech (TTS) pipeline faces a linguistic phantom: "The Unwritten Vowels" and "The Silent Destructors."

If your Grapheme-to-Phoneme (G2P) tokenization layer evaluates Thai text purely by surface-level characters, the synthetic voice will fail instantly. For an AI to read Thai naturally, it must learn the hidden architectural transformations of vowels shifting forms, vanishing entirely, or explicit rules where letters exist solely to be muted—except when they aren't.

1. The Shifting Metamorphosis: Vowels Modifying and Vanishing

In traditional Thai grammar, the arrival of a final consonant (ตัวสะกด) completely rewrites the visual representation of certain vowels. A TTS front-end cannot just split strings into independent tokens; it must evaluate clusters.

A. Vowel Mutation (สระเปลี่ยนรูป)When a short vowel gets a final consonant, its visual token undergoes a radical structural shift.The Short "A" (สระอะ - ะ): When standalone, it is written as "ะ" (e.g., ก + ะ = กะ). But the moment a final consonant is appended, it mutates into Mai Han-Akat (  ั ).
Visual Target: "กัน" (ก + ั + น)
Phonetic Reality for AI: The engine must map this back to the short open-mid vowel /a/. It is not G-U-N in Western terms, but an abrupt, clipped atomic block: K + a + n.

2. The Silent Destructors: Than thakhat (์) and the Transliteration Dilemma

The Than thakhat marker (์), commonly known as Garan, is a mathematical "kill switch" for text tokenization. Its primary job in modern Thai is to mute the consonant (and sometimes the preceding vowel) it sits on, a feature heavily deployed for adopting foreign loanwords.

The Tech Loanword Breakdown: "เซิร์ฟเวอร์" (Server)
When Thai people write "เซิร์ฟเวอร์", the "ร" and "ว" are visually there, but modern central Thai pronunciation strips the Western "R" sound away, resulting in:



A Technical Note on Pronunciation Fidelity:
From a strict engineering and linguistic standpoint, relying entirely on localized colloquial speech engines causes a significant loss of information. When tokenizing loanwords like "Server", the target output should ideally preserve the structural phonetics of the source language to remain universally accurate, rather than completely flattening it to the localized conversational form.

3. The Pāli Exception: The Rebirth of the Silent Letter

The absolute peak of computational complexity for a Thai TTS engine happens when dealing with Pāli Karaoke (ภาษาบาลีคาราโอเกะ / คำสวดมนต์). In Pāli texts written via the Thai script, the rules of the Than thakhat ("์") change entirely. Instead of acting as a mute switch, it frequently signals an implicit, subtle short "A" ($สระอะ$) sound or an initial consonant cluster blend.Consider the sacred opening phrase:


  • The Computational Trap: A standard consumer-grade G2P model will see "ส์" and instantly mute the "ส", rendering the word incorrectly as "วากขาโต".
  • The TTS Resolution Algorithm: For script-to-pitch processing in textual or religious datasets, the tokenizer must recognize the Pāli context. The "ส์" here acts as a structural trigger forcing a brief, light introductory vowel expansion—inserting an implicit short open prefix (/sa-/) and driving an อักษรนำ (high-consonant leading shift) into the following syllable.

Vowel Reduction (สระลดรูป)

Beyond mutation, certain vowels partially or completely vanish from the visual layer when a final consonant or tone marker interacts with them.
  • The Short "Eh" (สระเอะ - เ-ะ): In an open syllable, it uses the front เ and trailing ะ. When a final consonant is added, the ะ disappears, replaced by Mai Taikhoo (   ็ ).
    • Visual Target: "เป็น" (เ + ป + ็ + น)
    • Phonetic Reality for AI: The Mai Taikhoo here acts as a physical acoustic brake. The AI must realize this is not a tone modifier, but a duration controller instructing the wave generator to produce a highly clipped, short /eh/ vowel with a sudden glottal cutoff.
  • The Complex "Oer" (สระเออะ - เ-อะ): This represents the ultimate computational trap where vowel reduction and tone modulation collide.
    • Visual Target: "เพิ่ง" (พ + เ-อะ + ง + ไม้เอก)
    • Phonetic Reality for AI: The vowel components shift dramatically. The AI must map the underlying structure back to สระเออะ, identify "พ" as a Low-Class Consonant, and apply the Mai Ek ( ่ ) marker. Under these explicit parameters, the pitch trajectory cannot remain flat; it mathematically shifts into a high-descending curve—the Falling Tone (เสียงโท).
  • The Vanishing Short "Oh" (สระโอะ - -โ-ะ): This is the ultimate visual illusion in Thai text. When a mid-syllable short "Oh" takes a final consonant, the vowel markers completely vanish.
    • Visual Target: "นก" (น + ก) = น +โอะ + ก  Nk
    • Phonetic Reality for AI: The screen shows only two consonants (N-K). The AI must not treat this as a consonant blend; it must programmatically insert a hidden, short-clipped /o/ sound between them before calculating the tone trajectory based on the Low-Class Consonant (น) and the Dead Syllable ending (ก).
  • The Truncated Vowel Glide "Ua" (สระอัว - -ัว):
    • Open form: "ตัว" (ต + ั + ว) — retains both Mai Han-Akat ั ) and Wo Waen ().
    • Reduced form: When a final consonant is appended, the Mai Han-Akat completely evaporates, leaving only Wo Waen.
    • Visual Target: "กวน" (ก + ว + น)
    • Phonetic Reality for AI: The AI tokenizer must not confuse the remaining "ว" as a final consonant or a standalone consonant; it must decode it as the core vowel glide /ua/ bound to the Mid-Class Consonant (ก).
  • The Transforming "Eer" (สระเอือ - เ-ือ): When combined with a final consonant, the base vowel keeps its form, but its behavior dictates strict alignment with the consonant class rule.
    • Visual Target: "เลือก" (เ + ล + ื + อ + ก)
    • Phonetic Reality for AI: "ล" is a Low-Class Consonant. When combined with the long vowel glide สระเอือ and stopped by a Dead Ending (ก), it forces the AI to execute a sharp, high pitch modulation (เสียงโท) despite having zero visual tone markers on the screen.
  • The Disappearing "Oea" (สระเอีย - เ-ีย): Similarly, the visual components of สระเอีย remain intact when a final consonant is added, but it hides an acoustic trap for tone routing.
    • Visual Target: "เรียก" (เ + ร +  ี + ย + ก)
    • Phonetic Reality for AI: Just like the previous case, the Low-Class Consonant (ร) combined with a long vowel glide ended by a dead stop (ก) shifts the acoustic model into a High-Falling Tone (เสียงโท). The AI cannot map this tone purely by looking for a marker; it must calculate it from the hidden phonetic matrix of the syllable itself.
  • The Fused Mid-Central "Oer" (สระเออ - เออ): This vowel changes its visual structure entirely depending on the final consonant, splitting into two distinct behaviors.
    • Behavior 1 (Mutation): When followed by any standard final consonant (except ย), the trailing อ transforms into Sra I (   ิ ), as seen in "เดิน" (เ + ด + ิ + น). The AI must map the เ-ิ combination back to the long vowel /ɤː/.
    • Behavior 2 (Total Reduction): When the final consonant is "ย", the trailing อ disappears completely without leaving any visual trace.
    • Visual Target: "เคย" ( เ  + ค + ย)
    • Phonetic Reality for AI: The screen shows only เ + ค + ย. A basic tokenizer will misinterpret this as สระเอ (เ-) + ค + ย. The AI front-end must recognize this specific rule: if a word starts with เ-, ends with ย, and has a consonant in between, it is actually the long vowel /ɤː/ stopped by a palatal glide.
  • The Pseudo-Diphthongs with Hidden Endings (สระอำ, สระไอ, สระใอ, สระเอา): In traditional grammar, these are classified as "Extra Vowels" (สระเกิน), but computationally, they act as completely reduced syllables that carry their own built-in final consonants.
    • Visual Targets: "ดำ" (/am/), "ใจ" (/aj/), "ไป" (/aj/), "เบา" (/aw/)
    • Phonetic Reality for AI: These tokens break the standard linear structure because they contain an inherent short vowel + a hidden final consonant sound (/m/, /j/, /w/) embedded inside the vowel character itself. The AI must treat them as Live Syllables with Short Duration, which directly limits how the pitch can curve when interacting with tone classes.
  • The Hidden Vocalic R-Sounds (ฤ, ฤๅ, ฦ, ฦๅ): The ultimate linguistic shape-shifters. They function simultaneously as both a consonant and a hidden vowel base.
    • Visual Target: "ฤทธิ์" (Rit), "อังกฤษ" (Krit), "พฤษภาคม" (Phruet)
    • Phonetic Reality for AI: The character "ฤ" contains an unwritten vowel that can dynamically mutate into three entirely different sounds (/ri/, /rue/, or /roe/) based purely on the preceding consonant. The G2P layer must cross-reference this token against a specialized dictionary matrix before assigning the acoustic parameters.

Conclusion for System Architects

When training acoustic or text-preprocessing models for the Thai language, you cannot treat text as a simple sequential array of characters. You must implement a context-aware parser that handles:

  1. Consonant Class + Vowel Mutation Maps (Resolving(  ั  )and (  ็ ) back to their absolute raw phonetic durations).
  2. Contextual Killing vs. Expansion Flags (Differentiating whether (  ์ ) means "mute this token" for a tech word or "expand this token" for Pāli logic).

Decoding Thai Phonology for AI: Teaching Text-to-Speech Models Through the Lens of Traditional Bases and Tone Classes 3

 Decoding Thai Phonology for AI: Teaching Text-to-Speech Models Through the Lens of Traditional Bases and Tone Classes 3

From Script to Pitch: Demystifying the Four Tone Markers and Their Mathematical Behavioral Shifts for TTS.


Table Examaple Thai TTS WannaYuke Read and Text Form

Introduction: The Misconception of Four Markers

In many Western languages, diacritics represent a shift in vowel quality or a simple stress marker. In Thai, however, the four tone markers — Mai Ek (่), Mai Tho_o (้), Mai Trii (๊), and Mai Cattawaa (๋) — are instructions for pitch modulation.

A common pitfall when training AI models on Thai text is assuming a direct, 1-to-1 mapping between a tone marker and the resulting acoustic tone. In reality, a tone marker does not possess a fixed sound; its phonetic output is entirely governed by the initial consonant class (High, Mid, Low) and the syllable structure (Live or Dead syllable). For a Text-to-Speech (TTS) engine to achieve natural-sounding inflection, it must learn the underlying algorithmic rules of these markers rather than mapping them superficially.

The Four Markers and Their Behavioral Shifts

To teach an AI model effectively, we must break down how these markers mathematically alter the pitch trajectory based on the traditional grammar rules.

1. Mai Ek (่) : The Stabilizer of Lower Pitches

Phonetic Behavior:
When applied to Mid and High-Class consonants, Mai Ek forces the pitch into a Low Tone (a flat, sustained lower frequency).
When applied to Low-Class consonants, it acts differently, shifting the pitch into a Falling Tone (starting high, then dropping rapidly).
TTS Blueprint: The model must identify the initial consonant class first. If the token is “ค่า” (Low Class + Mai Ek), the target pitch contour must be a steep descent, not a steady low pitch.

2. Mai Tho_o (้) : The Dynamic Descender

Phonetic Behavior:
For Mid and High-Class consonants, Mai Tho_o produces a Falling Tone.
For Low-Class consonants, it pushes the pitch into a sharp High Tone (or a high-rising/glottalized pitch in central Thai dialect).
TTS Blueprint: This is where acoustic models frequently stumble. The visual marker is identical, but “ข้า” (High Class) and “ค้า” (Low Class) require entirely distinct $F_0$ (Fundamental Frequency) curve shapes in the synthesis pipeline.

3. Mai Trii (๊) & Mai Cattawaa (๋) : The Mid-Class Exclusives

Phonetic Behavior:
Mai Trii creates a distinct High Tone.
Mai Cattawaa creates a Rising Tone (starting low, then sweeping upward).
TTS Blueprint: In traditional phonology, these two markers are strictly reserved for Mid-Class consonants (and certain onomatopoeic loanwords). Because their usage is highly predictable and limited, the model can easily map them to consistent high and rising pitch contours, making them the most straightforward markers for an AI to learn.

The Computational Formula for Tone Resolution

For data pre-processing or creating a custom Grapheme-to-Phoneme (G2P) conversion script, the relationship can be visualized as a systematic function:

Acoustic Tone = f(Consonant Class, Syllable Ending, Tone Marker)

Without hardcoding this linguistic logic into the tokenization layer or feeding the model a deeply balanced phonetic dataset, the AI will struggle with homographs and tone shifting, resulting in a synthetic voice that sounds unnaturally robotic or flat to a native speaker’s ear.

Decoding Thai Phonology for AI: Teaching Text-to-Speech Models Through the Lens of Traditional Bases and Tone Classes 2

 Decoding Thai Phonology for AI: Teaching Text-to-Speech Models Through the Lens of Traditional Bases and Tone Classes 2

Mapping Vowel Coordinates and Acoustic Anchors for Flawless Voice Synthesis.

Ever wondered why Westerners or AI models often struggle with Thai vowels, turning ‘Karaoke’ into ‘Kara-o-kee’ or splitting words awkwardly? The secret lies in acoustic positioning and clipping the airflow.

Here is a definitive, no-nonsense guide mapping Thai vowels directly to English vocal anchors — designed specifically to ensure 100% pronunciation stability without any technical bugs.


Sara in Thai Reading VS English spell and pronouncing

Part 1: Monophthongs (Pure Vowels — Short vs. Long Pairs)

“Mastering the Short & Long Pairs: How to hit the precise vowel length and when to use the ‘abrupt cutoff’ technique for short Thai vowels.”
สระเดี่ยว (Monophthongs) — เรียงคู่ สั้น-ยาว
อะ
a (as a Prefix / Open Syllable, e.g., “about”)
u (as a Short Vowel in a Closed Syllable, e.g., “but, cut, up, humm”)
อา ar (Sustained R-controlled vowel, e.g., “ar mar”)
อิ i (as a Short Vowel in a Closed Syllable, e.g., “pin, bin, sit”)
อี ee (as a Long Digraph Vowel, e.g., “see, meet, free”)
อึ ue (as a Short Central Vowel, e.g., “dueng” — ดึง)
อือ uerm (as a Sustained Flat-Lipped Vowel, e.g., “Luerm” — ลืม, ฮืม — hmm)
อุ u / oo (as a Short Near-Close Vowel, e.g., “look, book, push”)
อู oo / u (as a Sustained Rounded Vowel, e.g., “you, tool, cool”)
เอะ eh (Pronounced short and clipped, e.g., “Keh” — เกะ, “Teh” — เตะ, Karaokeheh)
Pronounced as the short “e” in “bet” or “met”, but cut off abruptly before the final consonant
The “e” sound in words like “Bet”, “Met”, or “End” (but without the final consonant)

— -
เอ A or Ay (Long Vowel, pronounced exactly like the letter “A”)
Example: ABAC (เอแบค) or Bay (เบ), Pay (เพย์)
— -
แอะ aeh or ah (Pronounced short and clipped, e.g., “Gaeh” — แกะ / “Gaeh-Glong” — แกะกล่อง)
— -
แอ a (Positioned between consonants, e.g., “Hang”)
โอะ / โอ๊ะ Oh! (Pronounced short and clipped, e.g., “Oh!” when surprised)
oh (with a sudden stop, e.g., “Poh” — โป๊ะ, “Toh” — โต๊ะ)
- Phonetic Behavior: Standard English lacks a pure standalone short /o/ (which usually shifts to /ɒ/ as in “pot”). To achieve “โอะ”, Westerners must produce a “Clipped Vowel” by abruptly cutting off the airflow right after starting the “Oh” sound.
- Acoustic Anchor: Think of the natural, sudden exclamation “Oh!” when someone is startled — that exact short, sudden burst is the precise coordinate for “โอ๊ะ”.

โอ o (as a Sustained Mid-Close Vowel, e.g., “Go, No, So”)
เอาะ o (as a Short Open Vowel, e.g., “pot” — พ็อต, “cop” — ค็อป)
ออ or (as a Sustained Mid-Open Vowel, e.g., “for, door, or”)
เออะ (oe)
— —
เออ ur (as a Sustained Mid-Central Vowel, e.g., “surf, burn, hurt”)

Part 2: Diphthongs (Blended Vowels — Short vs. Long Pairs)

“Gliding Sounds Made Easy: Navigating Thai blended vowels by anchoring them to natural English shifting sounds.”

สระประสม (Diphthongs) — เรียงคู่ สั้น-ยาว
เอียะ (ia)
เอีย eung (as a Diphthong Vowel, e.g., “deung” — เดียง)
เอือะ (uea), เอือ (ueaa), อัวะ (ua), อัว (uaa)

Part 3: Special & Archaic Vowels (Vowels with Hidden Final Consonants)

“The Special Characters: From daily nasal sounds like ‘ใอ’ to rare archaic vowels found only in ancient historical texts.”
สระเกิน/สระที่มีเสียงพยัญชนะท้าย (Special Vowels)
อำ um (as a Short Nasal Vowel, e.g., “dum” — ดำ, “hum, sum”)
ไอ I (as an Open Diphthong Vowel, e.g., “I”, “idea” — when placed at the beginning of a word)
ใอ I / ai (as an Open Diphthong Vowel, e.g., “I”, “Mai” — ใหม่)
- Phonetic Behavior: Scientifically, “ใอ” shares the exact same acoustic coordinate as “ไอ”. The vocal tract opens wide and glides into a close-front position (starting from /a/ and ending at /i/), producing the perfect “AI” sound.
- Cultural Context: In traditional Thai grammar, this specific vowel is famously taught to children through a classic 20-word mnemonic poem called “Phu-Yai Ha Pha Mai…” (ผู้ใหญ่หาผ้าใหม่…).
- Implementation Logic: To prevent AI or Western speakers from mispronouncing or splitting syllables, anchoring this vowel to globally recognized references like I or the common name Mai ensures 100% stability without any technical bugs.
เอา ao (as a Closing Diphthong Vowel, e.g., “Kao” — เคา)
ฤ (รึ) (rue) Pronounced as a combined “R” and short “u/oo” sound, like “Roo”
Example: Rue-Doo (ฤดู — Season)
— -
Status: Archaic vowels. Used only in ancient Thai literature and historical documents; no longer used in modern everyday Thai.
ฤๅ (ruee)
ฦ (lue)
— -
ฦๅ (luee)
“Next Up: Decoding Thai Tones.”
“Now that we have nailed the vowel coordinates, the real magic of the Thai language happens here. Get ready for the next chapter, where we will crack the code of the 5 Thai Tones: Mid (สามัญ), Low (เอก), Falling (โท), High (ตรี), and Rising (จัตวา) — mapping them out simply so anyone, or any AI, can hit the perfect pitch every single time!”


PDF Text Layers are Killing Thailand’s Digital Reading Culture

 Ctrl + F and the Ghost Spaces: A Plea for Better Thai PDF Engine Rendering

It has long been a common, yet frustrating, stereotype that Thai people read very few books a year. But as we transition into a fully digital era where historical archives, religious texts, and academic papers are hosted online, a deeper, systemic issue comes to light. The problem isn’t always a lack of desire to learn; often, it is the technology itself that blocks access.

Anyone who has ever conducted research using Thai language PDFs knows the silent agony of pressing Ctrl + F, typing a keyword clearly visible on the screen, only to be met with: ‘No matches found.’

Behind the beautiful typography displayed on our screens lies a broken, chaotic ‘Text Layer’ — a digital mess of misplaced vowels and invisible, ghostly word spaces that render search engines blind. When technology fails to provide seamless searchability, users experience friction, frustration, and ultimately, disengagement. They simply close the file. In a sense, poorly optimized PDF engines are inadvertently destroying Thailand’s digital reading and research culture.

Drawing from the technical insights of our previous discussion on how text layers behave under the hood when exported from applications like LibreOffice and read via specialized engines like SumatraPDF, this article is a plea. It is a respectful call to action for global PDF converter developers and software engine creators to recognize the unique complexities of the Thai language, and to help us restore total freedom to the world of digital reading.



Thai PDF Text Layer Corruption: A major technical barrier for digital researchers.

The image clearly demonstrates the hidden chaos inside Thai digital documents. On the left, the PDF appears perfectly formatted and readable to the human eye. However, when the text is copied and pasted into a plain text editor like Notepad (on the right), the underlying Text Layer is completely corrupted.

Due to faults in the PDF Reader Engine, vowels are misplaced, words are shattered, and invisible ‘ghost spaces’ are injected into the text. Consequently, researchers are forced into a tedious and time-consuming process of manually editing and reconstructing this chaotic text before it can even be used.


An Appeal to Global PDF Converter and Reader Engine Developers

In an era powered by AI, Big Data, and total digital transformation, a PDF document can no longer exist simply to look pretty on a screen. The underlying Text Layer has become a critical piece of infrastructure — the very foundation that feeds human research, knowledge indexing, and machine learning.

Therefore, we respectfully appeal to global developers of PDF converters and rendering engines. We urge you to look closer at the unique structural complexities of the Thai language. By optimizing your algorithms to correctly sequence Thai characters and accurately process non-spaced text, you can eliminate the hidden chaos of corrupted layers and ghost spaces.

This is not just a software patch; it is an investment in human knowledge. Resolving this issue will tear down an invisible barrier, building a robust digital foundation that restores true freedom of reading and research to millions in the digital age.


Thursday, July 16, 2026

Decoding Thai Phonology for AI: Teaching Text-to-Speech Models Through the Lens of Traditional Bases and Tone Classes 1

 The Blueprint of Thai Phonation: How Classifying Consonants by Articulation and Tri-Yang Upgrades AI Speech Synthesis


Thai Phonetics Bases VS TRI-YARNG (Tone of Characters)

Introduction: The Missing Link in Thai Speech Synthesis

When we listen to modern AI-generated voices, the progress is undeniable. Text-to-Speech (TTS) models can now speak naturally, mimic human emotions, and even capture subtle breaths. Yet, when these advanced global models encounter the Thai language, they often stumble upon an invisible tonal wall. Thai is not just a language of words; it is a complex acoustic architecture where a single shifting tone transforms the entire meaning of a sentence.

Most contemporary AI training treats Thai text as flat sequences of data, relying purely on deep learning to brute-force the pronunciation. But to truly unlock flawless, natural Thai speech synthesis, we must look backward to leap forward. We need to bridge the cutting-edge world of neural networks with the ancient, time-tested engineering of traditional Thai phonology.

This article introduces the ultimate blueprint for Thai phonation — a structural synthesis that merges Traditional Phonetic Bases (ฐานกรณ์), which dictate where and how a sound is physically born in the human vocal tract, with Tri-Yarng (Sound Tone of Characters or ไตรยางค์), the historic tonal classification system. By teaching AI models to understand these foundational pillars, we move beyond simple text-to-speech conversion and begin engineering a system that truly comprehends the mechanics of the Thai voice. Here is how decoding ancient linguistics can radically upgrade modern AI speech technology.

Decoding the Matrix: How the Table Works

To the untrained eye, this table might look like a simple grid of Thai characters. However, for an AI engineer building a Text-to-Speech (TTS) model, this is an Acoustic Matrix — a two-dimensional instruction set that dictates both the physical waveform creation and the pitch modulation of the Thai voice.

Let’s break down the two core dimensions of this blueprint:

1. The Vertical Axis: Phonetic Bases (ฐานกรณ์) — The Physical Waveform Generators

Phonetic bases tell the AI model exactly where and how the sound resonance must be physically generated within the human vocal tract. For a neural network generating raw audio (like WaveNet or Vocoders), this translates to specific frequency characteristics:

1. Kanthaja (Throat / Glottal Base): Sounds like ก, ข, ค originate deep in the throat. There is no tongue constriction in the oral cavity, creating a deep, unobstructed baseline sound.

2. Taluja (Palatal Base): Characters like จ, ฉ, ช require the middle of the tongue to press against the hard palate. This creates a high-frequency friction or air-squeezing effect that AI must replicate.

3. Mutthaja (Alveolar / Retroflex Base): Sounds like ร, ล, ณ involve curling or touching the alveolar ridge. This is crucial for engineering natural “trills” or lateral airflow sounds — areas where AI voices often sound robotic.

4. Tantaja (Dental Base): For ด, ต, ท, ส, the tongue contacts the back of the front teeth, creating sharp, plosive, and sibilant boundaries.

5. Osthaja (Bilabial / Labial Base): Sounds like บ, ป, พ, ม are formed by sealing and bursting the lips. The AI must calculate a 100% air block before a sudden waveform release.

6. Mixed/Special Bases (e.g., Tantosthaja): The character ว is an advanced joint-articulation where the upper teeth touch the lower lip while forming a rounded shape. This requires a two-step vocal tract simulation.

2. The Horizontal Axis: Tri-Yarng (Tone Classes) — The Pitch Multiplier Rules

While the Phonetic Bases determine the shape of the sound wave, Tri-Yarng acts as the Tone Mapping Rules. It functions like a mathematical multiplier that determines the Fundamental Frequency ($F_0$) Contour of a syllable when combined with vowels and final consonants:

Middle Consonants (อักษรกลาง): Operating as the stable Baseline (0), this group can organically morph into all 5 tones matching their exact written tone marks. It is the easiest class for deep learning models to predict.

High Consonants (อักษรสูง): Possessing an inherent rising tone as their default state, these characters are accompanied by heavy air aspiration. The AI must initiate the sound wave at a higher pitch frequency.

Low Consonants (อักษรต่ำ): This is the ultimate trap for modern TTS engines. This class features “Hidden Shifting Rules” — for instance, a first tone mark (Mai-Ek) actually forces a falling tone, and a second tone mark (Mai-Tho) shifts into a high tone. Without understanding this rule, a global AI model will consistently mispronounce Thai words.

The Developer’s Takeaway

By feeding this Matrix into a Thai TTS Text-Parser, the AI no longer sees the character พ (Phor Pharn) as a flat piece of text. Instead, the system instantly processes a dual command:




 This dual-layered understanding drastically upgrades the accuracy of the synthesized voice, eliminating awkward accents and making AI speech indistinguishable from a native speaker.


Transition: The Dynamic Engine of Thai Vowels (สระ)

While consonants act as the physical structural pillars and tone initiators of the Thai language, they remain static without the engine that drives them forward: Vowels (สระ — Sra).

In Thai phonology, vowels are not just simple letters placed next to a consonant; they are highly dynamic, multi-dimensional audio modulators. From a digital speech synthesis standpoint, if consonants define the initial acoustic boundary, vowels dictate the duration, formant frequencies, and sustained pitch trajectory of the synthesized voice.

To train an AI model to articulate Thai vowels naturally, developers must understand that Thai vowels operate on two critical engineering principles: Acoustic Length (Short vs. Long Vowels) and Spatial Positioning (Non-Linear Text Topology). Let’s decode how these vowel mechanics work inside the AI Text-Parser.


Stay Tuned for Part 2: Engineering the Thai Vowel

Engine Understanding the relationship between consonants and phonetic bases is only half the battle. To stop AI models from mispronouncing vowels — like stumbling over the notorious “อึ / อือ” (ɯ) or mistaking a sustained “อา” for a flat sound — we must completely overhaul how text parsers map these sounds to global acoustic engines.In the next part of this series, we will dive deep into the actual data preparation for Thai vowels. We will explore how replacing legacy Romanization with an AI-friendly, acoustic-driven mapping (such as shifting from the confusing aa to a more natural ar, and mastering the ue / uee framework) can completely eliminate foreign accents in synthetic speech.We will also decode the “Spatial Positioning Problem” — how to teach a linear AI model to read Thai vowels that are written above, below, before, or even wrapped around a consonant.Don’t miss the next chapter of the blueprint. Follow along to unlock the code behind flawless, natural Thai speech synthesis.



Monday, July 13, 2026

Why Thai Text Layers Break in PDFs: The Broken Pipeline of Conversion and Rendering

 Why Thai Text Layers Break in PDFs: The Broken Pipeline of Conversion and Rendering

Exploring the structural flaws of Thai fonts and text layer engines when converting docs to PDF and extracting data.


Part 1: The Root of the Document — TrueType Fonts (TTF) and Open Formats

The integrity of a Thai PDF text layer begins long before the “Export to PDF” button is ever clicked. It starts at the very origin of the data pipeline: document authoring.

To understand why Thai script breaks so easily, we must look at how characters are handled at the root. For this workflow, the process initiates with two critical decisions:

1. The Choice of Font Engine: TrueType Fonts (.TTF)
Unlike Western scripts where characters sit sequentially on a single baseline, Thai is a multi-level script. Vowels and tone marks can sit above or below the consonant (e.g., สระ, วรรณยุกต์).

Using standard TrueType Fonts (TTF) ensures that each glyph, combined character, and positioning coordinate is fully mapped within the font’s internal tables. When formatting Thai text, relying on system-native TTF structures provides a clean digital anchor for each character component, ensuring that the software recognizes the script’s absolute layout rather than just treating it as a visually combined graphic block.

2. Document Authoring with LibreOffice and the .DOCX Standard
Instead of using restrictive proprietary software, the initial document drafting and editing are performed using LibreOffice, a powerful open-source office suite.

The Editing Process: LibreOffice provides robust compliance with complex script types, making it highly reliable for managing the intricate spacing requirements of Thai formatting without introducing hidden formatting metadata that could corrupt the layout.

The File Structure: Once the text and layout are finalized, the document is saved in the .docx format. This XML-based architecture preserves the explicit structural hierarchy, formatting flags, and font mappings of the Thai text blocks, setting up a completely predictable framework before the conversion engine takes over.

However, saving a perfectly structured .docx file with the correct .ttf fonts in an offline editor is only half the battle. The real challenge — and where most automated systems break down — lies in how this structural pipeline transitions from an editable format into a static PDF text layer.



Part 2: The Silent Culprit — How PDF Readers Break the Thai Text Layer

Even if a document is perfectly authored with compliant TrueType fonts and converted via a clean engine, the battle for a flawless Thai PDF is only halfway won. The final, and often overlooked, link in this digital pipeline is the PDF Reader Engine itself.

For Western languages, rendering a text layer is a straightforward, sequential operation. But for complex, multi-level scripts like Thai — where vowels and tone marks stack above and below consonants — the PDF Reader must do more than just display shapes; it must reconstruct the correct text stream behind the scenes.

The Impact on Search and AI Text-to-Speech (TTS)
When a PDF Reader fails to interpret the positional metadata of Thai characters properly, the underlying Text Layer becomes deeply corrupted. This breakdown triggers two major technical failures:

Broken Searchability: If the reader engine fails to map the stacked vowels and consonants in their true linguistic sequence, the “Ctrl + F” search function fails entirely. Words are treated as broken fragments rather than continuous strings.

AI Text-to-Speech (TTS) Distortion: Modern AI narration and TTS engines rely heavily on the browser or reader’s text extraction layer to read documents aloud. If the reader extracts a corrupted text layer where tone marks are misplaced or character spaces vanish, the AI engine will mispronounce words, completely ruining the natural speech flow.

The Discovery: Why SumatraPDF is the Solution
Through rigorous testing of various PDF readers and browser-integrated PDF viewers — which often suffer from severe rendering and extraction bugs when handling Thai script — I discovered a powerful exception: SumatraPDF.

SumatraPDF stands out because of its lightweight yet highly accurate text rendering architecture. When opening a Thai PDF in SumatraPDF, the software executes a precise character-mapping process:

Perfect Font Mapping: It flawlessly handles the embedded .ttf tables, ensuring that the visual layout matches the semantic data layer perfectly.

Clean Text Extraction: Unlike heavy, bloated readers that distort word spaces or misplace floating vowels upon extraction, copying text from SumatraPDF into a plain text editor reveals a 100% accurate, uncorrupted layout.

By utilizing SumatraPDF as the primary reader, we ensure that the Thai text layer remains completely intact, perfectly searchable, and fully optimized for AI narration tools without any distortion.




Part 3: The Unicode Illusion — Why Web Browsers and AI TTS Engines Fail

When a PDF is viewed through a standard Web Browser (such as Chrome, Edge, or Safari), the integrated PDF viewer processes the document using standard web technologies. These browsers read the underlying data stream primarily via Unicode (UTF-8 or UTF-16) character encodings. While Unicode is the global standard for text interchange, its implementation within browser-based PDF rendering engines introduces a catastrophic breakdown when handling Thai script.

1. The Logical vs. Visual Processing Trap

In a standard text file or web page, Thai Unicode characters are typed sequentially (Consonant + Vowel + Tone). The operating system’s rendering engine automatically handles the visual stacking.

However, a PDF file operates on a Coordinate-Based Postscript System. It tells the reader exactly where to draw a glyph on a 2D plane. When a browser’s layout engine attempts to extract text from a PDF, it tries to map these absolute visual coordinates back into a logical Unicode stream. Because Thai vowels and tone marks sit on different vertical levels (above or below the baseline), the browser gets confused. It fails to reassemble the characters in their correct linguistic sequence, causing tone marks to detach, slide to the next character, or drop onto their own broken lines, as clearly demonstrated when pasted into a plain text editor.

2. The Impact on Browser-Based Search (Ctrl + F)

Because the browser’s internal text layer thinks the word “เอกสารชั้นต้น” is structurally written as a fragmented sequence of separated consonants and floating marks, the built-in search indexing fails completely. If you search for the correctly spelled word, the browser’s search engine cannot find a match because the text layer it “sees” is a garbled string of broken characters.

3. Why AI Text-to-Speech (TTS) Programs Synthesize Corrupted Audio

This dual-failure of conversion and browser rendering is exactly why modern application-based Text-to-Speech (TTS) tools read Thai PDFs with heavy distortion.

Most AI voice synthesis tools and screen readers do not look at the visual rendering on the screen; they inject a script to scrape the raw text layer directly from the browser’s PDF engine. When the script extracts a corrupted Unicode text stream where spaces vanish and characters are scrambled, the AI reads the text literally as it is extracted. The result is a broken, robotic, and completely unnatural narration that completely ruins the user experience.



Part 4: The Ultimate Local Pipeline — Preserving Thai Bookmarks and Structural Integrity

To build a professional digital archive or technical document, preserving the text layer is only one side of the coin. The other critical requirement is maintaining the document’s structural navigation, such as Bookmarks and Headers (Table of Contents).

When relying on cloud engines or mainstream browsers to handle Thai documents, creators are often forced to choose between a functional navigation tree or a searchable text layer. By shifting to a completely local pipeline, we can secure both.

1. Advanced Source Authoring with LibreOffice (The Power of Native Bookmarks)

The foundation of a reliable Thai PDF relies on generating a permanent, pre-compiled structure locally.

Structuring with Intent: During the drafting stage in LibreOffice, using standard TrueType Fonts like Noto Sans Thai, the document is organized with proper heading styles (H1, H2, H3).

The Embedded Architecture: When saving as a .docx file or exporting directly via LibreOffice, the software injects explicit Bookmark metadata into the file. This process binds the Thai heading text directly to the document’s navigation tables, preventing the text drift or font substitution that typically destroys Thai character mapping when processed by cloud-based conversion platforms.

2. Seamless Navigation and Flawless Extraction in SumatraPDF

The real magic happens when this properly authored document meets SumatraPDF. While Chromium-based browsers (Chrome/Edge) strip away or glitch out when processing complex Thai index structures, SumatraPDF processes the local file perfectly:

Intact Navigation Tree: Upon opening the document, the Bookmark panel renders flawlessly. Users can click through the Thai headers to navigate deep into the document without encountering corrupted symbols or broken character rendering.

100% Searchable and Extractable: As proven by real-world testing, typing a specific phrase like “เอกสารชั้นต้น” into SumatraPDF’s search engine immediately hits the target. Copying that exact text block out of the reader and dumping it into Notepad preserves every single character, floating vowel, and tone mark in its exact linguistic order.

Conclusion

Achieving a bulletproof, professionally navigable Thai PDF does not require cloud-based AI processing or heavy proprietary ecosystems. It requires technical discipline at the source. By structure-mapping documents locally with LibreOffice’s native bookmarks and deploying SumatraPDF as the final verification gate, engineers and archivists can produce pristine Thai digital documents that are structured for navigation, fully searchable, and completely ready for perfect AI Text-to-Speech integration.











Tuesday, July 8, 2025

OS 9.2.2 & Apps: Disk Usage

 Disk Space Analysis

This section (or series of posts) will be the core of our exploration, diving deep into the actual storage consumption on the iMac G3 after the complete installation of Mac OS 9.2 and its associated applications.

Application and Update Descriptions

These programs were essential components of the Mac OS 9.2.2 experience during that era, each with its specific role, function, and key features.

1. Mac OS 9.2.2 Update

Type: Operating System Update

Primary Function: Not a standalone application, but the final and most complete update for Mac OS 9.x.

Key Features/Significance:

Stability and Compatibility: Addresses bugs, improves system stability, and enhances compatibility with later hardware and software releases of that period.

Network Connectivity: Improves network capabilities, especially with AirPort (Apple's early Wi-Fi).

Performance: Offers overall system performance enhancements.

End of Classic Mac OS Era: Marked as the last official update to the Classic Mac OS line before the full transition to Mac OS X, making 9.2.2 the most stable and popular version for those who preferred to continue using Classic Mac OS.

Notes/Relevance: Essential for running certain applications that require the most stable version of Mac OS 9, and serves as the crucial foundation for your system.

2. QuickTime Player (Specifically QuickTime Player 6.0.3)

Type: Multimedia Player and Framework

Primary Function: Used for playing various multimedia files including video (MOV, AVI), audio (MP3, WAV), and animations.

Key Features/Significance:

Apple's Standard: QuickTime was Apple's core technology for multimedia handling during that era. .mov video files were widely prevalent.

Broad Format Support: Even for its time, it supported a wide range of media formats, including basic streaming capabilities.

Bug Fixes: Version 6.0.3 included improvements in stability and security compared to earlier versions.

System Integration: Often pre-installed with Mac OS or considered an essential component for compatibility with websites and other applications that utilized QuickTime for media playback.

Notes/Relevance: An indispensable basic program for watching videos or listening to audio in the Mac OS 9 era, and also served as a framework for other applications to handle media.




3. Thai Language Pack

Type: Language Extension / Localization

Primary Function: Adds the capability to display, input, and support the Thai language within Mac OS 9.2.2.

Key Features/Significance:

Correct Thai Display: Ensures that the operating system and various applications can correctly display Thai characters without corruption or "boxes."

Thai Input: Enables Thai keyboard input, allowing users to type documents or communicate in Thai.

Text Layout: May include improvements for Thai text layout and word-breaking.

Menus and Dialogs: Some parts of the system or applications might switch to Thai (depending on the level of localization).

Notes/Relevance: Absolutely essential for users in Thailand or anyone needing to work with Thai language documents on Mac OS 9.2.2. Without this pack, Thai language use would be difficult or incomplete.

4. SimpleText

Type: Basic Text Editor

Primary Function: Used for quickly creating, opening, viewing, and editing small text files (.txt).

Key Features/Significance:

Simple and Fast: A very lightweight application that opens instantly and requires minimal system resources.

Default Viewer: Often the default program used to open README files or general text documents that came with other software.

Text-to-Speech: Had the unique ability to convert text into spoken audio files using Mac's system voices (e.g., MacinTalk).

Basic Drawing: Also had basic bitmap graphic drawing capabilities, allowing users to create and save simple images (PICT files), though this wasn't its primary function.

Notes/Relevance: "that requires Mac OS 9.2.2 to be open at Startup first" – This means SimpleText is a fundamental application pre-installed with Mac OS 9.x and is ready to use as soon as the operating system boots up. It is not a separate program that needs additional installation; it's an integral part of the Classic Mac experience.




5. AppleWorks 6

Type: Integrated Productivity Suite (All-in-One Office Suite)

Primary Function: Combines multiple office application types into a single suite for creating a variety of documents.

Key Features/Significance:

Versatile Functions: Its biggest strength was integrating the capabilities of:

Word Processing: For writing documents and reports.

Spreadsheet: For calculations and numerical data management.

Presentation: For creating slideshows.

Database: For simple data management.

Drawing: For creating vector graphics.

Painting: For creating and editing bitmap images.

User-Friendly: Featured an intuitive interface, making it suitable for general users, students, or small businesses.

Compatibility: Could open and save files in various formats to some extent (e.g., basic Microsoft Word, Excel formats of that era).

Popularity in Classic Mac Era: A popular alternative office suite for Mac users when Microsoft Office wasn't as prevalent, or for those seeking a more cost-effective option.

Notes/Relevance: This application consumed a relatively large amount of disk space compared to SimpleText but provided comprehensive functionality for general office tasks of that period.

I hope this detailed explanation helps clarify the functions and highlights of each program you're running on your Mac OS 9.2.2!




Mac OS 9.2.2 & Essential Apps: Real-World Disk Usage on a 4GB USB Drive

Content Summary:
This post summarizes the actual disk space utilized by a complete installation of Mac OS 9.2.2, alongside key applications such as QuickTime Player 6.0.3, AppleWorks 6, the Thai Language Pack, and SimpleText, when deployed on a USB drive.

As demonstrated by the "Get Info" screenshot of the "4Gnew922" USB drive (with a usable capacity of 3.73 GB), the total disk space consumed by the operating system and these essential applications is precisely 849.3 MB. This leaves a substantial 2.9 GB of available space on the drive, indicating that even with these core components, the setup remains relatively compact and efficient for a vintage Mac OS environment. This measurement reflects the collective footprint of approximately 4,545 individual items.