Whitepaper: Hacking Kannada gTTS for Sanskrit Phonology

 

Abstract

As Text-to-Speech (TTS) models become increasingly advanced, they are heavily optimized for modern, conversational speech. While this yields natural-sounding voice assistants, it presents a unique challenge for generating audio for ancient, highly phonetic languages like Sanskrit. This paper documents the engineering and linguistic challenges encountered while adapting Google's Kannada TTS (gTTS) engine to accurately chant complex Sanskrit texts (specifically the Advaita Vedanta Bhashyas), and details the specific phonetic hacks required to bypass the neural model's conversational biases.

The Core Challenge: Conversational Bias vs. Phonetic Precision

Modern neural TTS models are trained on massive datasets of colloquial speech. In the case of the Kannada TTS engine, the model leans heavily toward the dominant conversational dialects (such as those of Bengaluru). This introduces several unwanted behaviors when processing Sanskrit:

  1. Linguistic Assimilation: Lazy articulation of complex consonant clusters.
  2. Conversational Drag: Unnatural elongation of word-final syllables to mimic human thought pauses.
  3. Aspiration Shifts: Merging alpa-prana (unaspirated) and maha-prana (aspirated) consonants due to regional colloquial influence.

Because the engine's internal phonemizer cannot be retrained locally, we had to intercept the text and apply invisible phonetic hacks—creating a custom text-preprocessing wrapper that tricks the engine into perfect pronunciation before the audio is ever generated.


Identified Bugs and Phonetic Solutions

1. The Dynamic Visarga (ः / ಃ)

The Problem: The visarga is a voiceless glottal fricative whose pronunciation dynamically changes based on the preceding vowel. Traditional South Indian chanting resolves the visarga phonetically as an echo of the preceding vowel (aḥ becomes aha, iḥ becomes ihi, uḥ becomes uhu, aiḥ becomes aihi). Modern TTS engines simply default to a generic "ha" (ह) sound for all of them, destroying the meter and phonetics (e.g., tasmaiḥ pronounced as tasmaiha).

The Fix: We implemented a dynamic Regular Expression preprocessor that intercepts the visarga and substitutes it with hardcoded phonetic equivalents based on the preceding vowel:

  • a / aa + visarga → ha / haa
  • i / ee / ai + visarga → hi
  • u / oo / au + visarga → hu
  • e + visarga → he
  • o + visarga → ho

2. The Rya (र्य / ರ್ಯ) Ligature Assimilation (The "Arrama" Roga)

The Problem: Complex consonant clusters involving the Repha (the 'r' sound preceding another consonant, known as arkavattu in Kannada typography) are notoriously difficult for TTS engines to articulate at high speeds. When the Kannada gTTS encountered the word अर्यमा (aryamā), the model lazily assimilated the 'y' into the 'r', producing a doubled r. The resulting audio sounded like अर्रमा (arrama).

The Fix: Breaking the ligature using invisible Unicode. We implemented a codebase-wide substitution replacing the standard r + virama + y with a hidden Zero-Width Non-Joiner (ZWNJ, \u200C):
र् + \u200C + (renders as ರ್‍ಯ in Kannada).
By forcing this micro-split in the text rendering, we forced the neural model to stop its lazy assimilation, take a microsecond pause, and articulate both consonants distinctly.

3. The Word-Final MakAra (म् / ಮ್)

The Problem: Sanskrit frequently uses words ending in a pure consonant 'm' with a halant/virama (e.g., ज्ञानम्). The TTS engine often struggled to neatly terminate the sound, sometimes awkwardly stretching the consonant.

The Fix: We intercepted any word-final m + virama and phonetically converted it into an Anusvara (ं / ಂ). The engine's acoustic model handled the Anusvara gracefully at word boundaries, producing a clean, resonant termination.

4. Accepted Quirks: Word-Final Elongation and Geminate Swallowing

Not all neural biases can be easily hacked. We observed two distinct quirks:

  • Conversational Drag: The engine elongates word-final short vowels (e.g., becomes चा, becomes रा), treating standalone words as conversational fade-outs.
  • Geminate Swallowing: The engine compresses double consonants at word boundaries (e.g., तस्मान्न compressed to तस्मान).

Attempted Fixes: We tested appending ZWNJs, ZWJs, hyphens, and commas directly to the syllables to force a short stop. However, doing so sometimes triggered a worse linguistic disease: schwa-deletion (similar to modern Hindi), completely killing the inherent 'a' sound (e.g., सत्यं वद became सत्यं वद्). Ultimately, we accepted the slight elongation of word-final as a stylistic conversational quirk rather than risk breaking the schwa entirely.


Conclusion

Adapting a modern conversational TTS engine for ancient Sanskrit chanting is an exercise in reverse-engineering neural biases. By treating the TTS engine as a black box and applying an intelligent, invisible phonetic wrapper (using Unicode joiners and regex substitutions), we successfully coerced an everyday Kannada voice model into a precise, resonant vehicle for ancient Sanskrit texts.