# Sanskrit Script Teacher The Sanskrit Script Teacher is a learning tool that helps readers understand the pronunciation of Devanāgarī script and IAST (International Alphabet of Sanskrit Transliteration). It operates entirely on the *display layer* of the website—it does not modify, interpret, or alter any book content. --- ## Overview When enabled, the Script Teacher: 1. **Parses** Devanāgarī text into individual syllables 2. **Displays** hoverable syllables with pronunciation guides 3. **Provides** an autoplay feature that walks through verses with authentic timing --- ## System Overview ``` ┌──────────────────────────────────────────────────────────────── │ SCRIPTURE PAGE │ ┌─────────────────────────────────────────────────────────┐ │ │ > धर्मक्षेत्रे कुरुक्षेत्रे समवेता युयुत्सवः । │ │ │ > मामकाः पाण्डवाश्चैव किमकुर्वत सञ्जय ॥१॥ │ │ └─────────────────────────────────────────────────────────┘ │ │ │ ▼ │ ┌─────────────────────────────────────────────────────────┐ │ │ SCRIPT TEACHER MODULE │ │ │ ┌───────┐ ┌───────┐ ┌────────┐ │ │ │ │ Parse │───▶│ Map │───▶│ Render │ │ │ │ └───────┘ └───────┘ └────────┘ │ │ └─────────────────────────────────────────────────────────┘ │ │ │ ▼ │ ┌─────────────────────────────────────────────────────────┐ │ │ [धर्म] [क्षे] [त्रे] [कु] [रु] [क्षे] [त्रे] ... │ │ │ ▲ │ │ │ │ hover │ │ │ ▼ │ │ │ ┌───────────────────┐ │ │ │ │ dharma │ │ │ │ │ dh: as "adhesion" │ │ │ │ │ Dental consonant │ │ │ │ └───────────────────┘ │ │ └─────────────────────────────────────────────────────────┘ └──────────────────────────────────────────────────────────────── ``` --- ## For the Technical Reader ### Architecture The Script Teacher is a client-side JavaScript module (`ScriptTeacher` in `publish.js`) that: 1. **Detects** Devanāgarī blockquotes on scripture pages 2. **Tokenizes** the text using Unicode-aware syllable parsing 3. **Maps** each syllable to its IAST transliteration 4. **Renders** interactive spans with hover tooltips 5. **Provides** autoplay with variable timing ### Data Flow ``` ┌────────────┐ ┌────────────┐ ┌────────────┐ │ SOURCE │ │ PROCESS │ │ OUTPUT │ │ (static) │ │ (runtime) │ │ (display) │ └─────┬──────┘ └─────┬──────┘ └─────┬──────┘ │ │ │ ▼ ▼ ▼ ┌─────────┐ ┌─────────┐ ┌─────────┐ │ .md │ │ Parse │ │ Styled │ │ files │──────▶│ Deva- │──────▶│ <span> │ │ │ │ nāgarī │ │ elements│ └─────────┘ └─────────┘ └─────────┘ │ │ │ │ ┌─────┴─────┐ │ │ ▼ ▼ │ │ ┌───────┐ ┌───────┐ │ │ │ IAST │ │sylMap │ │ │ │mapping│ │ cache │ │ │ └───────┘ └───────┘ │ │ │ └──────── UNCHANGED ─────────────────┘ Note: Source files are NEVER modified ``` ### Syllable Parsing The parser recognizes: - **Vowels** (स्वर): अ आ इ ई उ ऊ ऋ ॠ ए ऐ ओ औ - **Consonants** (व्यञ्जन): क ख ग घ... through ह - **Conjuncts** (संयुक्त): क्ष त्र ज्ञ श्र etc. - **Modifiers**: anusvāra (ं), visarga (ः), candrabindu (ँ), virāma (्) - **Punctuation**: daṇḍa (।), double daṇḍa (॥) ### IAST Mapping Each Devanāgarī character maps to standard IAST: | Devanāgarī | IAST | Type | |------------|------|------| | अ | a | Short vowel | | आ | ā | Long vowel | | इ | i | Short vowel | | ई | ī | Long vowel | | क | ka | Consonant + inherent a | | क् | k | Consonant (halant) | | क्ष | kṣa | Conjunct | ### Pronunciation Database The `PRONUNCIATION` object contains phonetic descriptions for each sound: ```javascript PRONUNCIATION = { 'a': 'as in "about"', 'ā': 'as in "father" (long)', 'i': 'as in "bit"', 'ī': 'as in "machine" (long)', 'k': 'as in "skip" (unaspirated)', 'kh': 'as in "inkhorn" (aspirated)', // ... etc } ``` ### Articulation Points The `ARTICULATION` object maps consonants to their place of articulation (based on Pāṇinian phonology): | Point | Sanskrit | Consonants | |-------|----------|------------| | Guttural | कण्ठ्य | k, kh, g, gh, ṅ | | Palatal | तालव्य | c, ch, j, jh, ñ, y, ś | | Retroflex | मूर्धन्य | ṭ, ṭh, ḍ, ḍh, ṇ, r, ṣ | | Dental | दन्त्य | t, th, d, dh, n, l, s | | Labial | ओष्ठ्य | p, ph, b, bh, m | ### Autoplay Timing Algorithm The autoplay uses authentic Sanskrit prosody: ``` ┌──────────────────────────────────────────────────────────────── │ TIMING CALCULATION FLOW ├──────────────────────────────────────────────────────────────── │ │ START │ │ │ ▼ │ ┌───────────────────┐ │ │ Get base duration │ ◄── User selects: Slow/Normal/Fast │ │ (800ms for Normal)│ │ └─────────┬─────────┘ │ │ │ ▼ │ ┌───────────────────┐ ┌───────────────┐ │ │ Is Guru syllable? │────▶│ YES: × 1.6 │ │ │ (long vowel/ṁ/ḥ) │ │ NO: × 1.0 │ │ └─────────┬─────────┘ └───────┬───────┘ │ │◄──────────────────────┘ │ ▼ │ ┌───────────────────┐ ┌───────────────┐ │ │ Has double daṇḍa? │────▶│ YES: +1.5×base│ (verse end) │ └─────────┬─────────┘ └───────┬───────┘ │ │◄──────────────────────┘ │ ▼ │ ┌───────────────────┐ ┌───────────────┐ │ │ Has single daṇḍa? │────▶│ YES: +0.8×base│ (pāda end) │ └─────────┬─────────┘ └───────┬───────┘ │ │◄──────────────────────┘ │ ▼ │ ┌───────────────────┐ ┌───────────────┐ │ │ Line break after? │────▶│ YES: +0.4×base│ (breathing) │ └─────────┬─────────┘ └───────┬───────┘ │ │◄──────────────────────┘ │ ▼ │ ┌───────────────────┐ │ │ Schedule next │ │ │ syllable with │ │ │ calculated time │ │ └───────────────────┘ │ └──────────────────────────────────────────────────────────────── ``` **Example timing for "धर्मक्षेत्रे" (dharma-kṣetre) at Normal speed:** ``` dharmakṣetre ────┬────┬── │ │ │ └── kṣe-tre: Guru (e is long) = 800 × 1.6 = 1280ms │ └─────── dhar-ma: Laghu (a is short) = 800ms ``` **Full verse timing visualization:** ``` धर्मक्षेत्रे कुरुक्षेत्रे समवेता युयुत्सवः । └─┬─┘└──┬──┘ └─┬─┘└──┬──┘ └─┬──┘└┬┘ └─┬──┘└┬┘ │ │ │ │ │ │ │ │ │ │ L G L G G L G L +pause │ │ │ │ │ │ │ │ │ 800 1280 800 1280 1280 800 1280 800 +640 (daṇḍa) L = Laghu (short) G = Guru (long) ``` ### Guru/Laghu Detection A syllable is classified as **Guru** (heavy, 2 mātrās) if it contains: - Long vowels: ā, ī, ū, e, ai, o, au, ṝ - Anusvāra: ṁ - Visarga: ḥ Otherwise it is **Laghu** (light, 1 mātrā). --- ## For the Sanskrit Scholar ### Phonological Authority The Script Teacher's pronunciation guide is based on: 1. **Pāṇini's Aṣṭādhyāyī** - The foundational Sanskrit grammar (c. 4th century BCE) which defines the śikṣā (phonetics) of Sanskrit sounds 2. **Traditional Śikṣā texts** - Including Pāṇinīya Śikṣā which describes the exact articulation points (sthāna) and articulators (karaṇa) for each sound 3. **IAST Standard** - The International Alphabet of Sanskrit Transliteration, the scholarly standard used by universities and academic publications worldwide ### Articulation Classification The five-fold classification of consonants by place of articulation (pañca-sthāna) follows the traditional order: | Sanskrit Term | English | Example | |---------------|---------|---------| | कण्ठ्य (kaṇṭhya) | Guttural | क (ka) | | तालव्य (tālavya) | Palatal | च (ca) | | मूर्धन्य (mūrdhanya) | Retroflex/Cerebral | ट (ṭa) | | दन्त्य (dantya) | Dental | त (ta) | | ओष्ठ्य (oṣṭhya) | Labial | प (pa) | **Articulation Points in the Mouth (Pāṇinian Model):** ``` ┌─────────────────────────────────── │ ORAL CAVITY │ SOFT PALATE ────┤ ┌───────────────────────────┐ (velum) │ │ 1. GUTTURAL (kaṇṭhya) │ │ │ क ख ग घ ङ (ka-varga) │ │ │ Throat/back of tongue │ │ └───────────────────────────┘ │ HARD PALATE ────┤ ┌───────────────────────────┐ │ │ 2. PALATAL (tālavya) │ │ │ च छ ज झ ञ (ca-varga) │ │ │ Middle tongue + palate │ │ └───────────────────────────┘ │ ROOF (dome) ────┤ ┌───────────────────────────┐ │ │ 3. RETROFLEX (mūrdhanya) │ │ │ ट ठ ड ढ ण (ṭa-varga) │ │ │ Tongue curled back │ │ └───────────────────────────┘ │ TEETH ──────────┤ ┌───────────────────────────┐ │ │ 4. DENTAL (dantya) │ │ │ त थ द ध न (ta-varga) │ │ │ Tongue touches teeth │ │ └───────────────────────────┘ │ LIPS ───────────┤ ┌───────────────────────────┐ │ │ 5. LABIAL (oṣṭhya) │ │ │ प फ ब भ म (pa-varga) │ │ │ Both lips │ │ └───────────────────────────┘ │ └─────────────────────────────────── ``` **The Sanskrit Consonant Matrix (Varṇamālā):** ``` VOICING & ASPIRATION ───────────────────────────────────────── Unvoiced Unvoiced Voiced Voiced Nasal Unaspirated Aspirated Unaspirated Aspirated ─────────── ─────────── ─────────── ─────────── ───── GUTTURAL क (k) ख (kh) ग (g) घ (gh) ङ (ṅ) PALATAL च (c) छ (ch) ज (j) झ (jh) ञ (ñ) RETROFLEX ट (ṭ) ठ (ṭh) ड (ḍ) ढ (ḍh) ण (ṇ) DENTAL त (t) थ (th) द (d) ध (dh) न (n) LABIAL प (p) फ (ph) ब (b) भ (bh) म (m) SEMIVOWELS य (y) र (r) ल (l) व (v) SIBILANTS श (ś) ष (ṣ) स (s) ASPIRATE ह (h) ``` ### Prosodic Timing (Chandas) The autoplay timing respects traditional prosody: - **Mātrā** (मात्रा) - The fundamental unit of syllabic duration - **Laghu** (लघु) - Light syllable = 1 mātrā - **Guru** (गुरु) - Heavy syllable = 2 mātrās The pause structure follows natural verse recitation: - **Pāda** (पाद) - Quarter verse, marked by single daṇḍa (।) - **Ardha-śloka** - Half verse - **Śloka** - Full verse, marked by double daṇḍa (॥) ### What This Tool Is NOT The Sanskrit Script Teacher: - **Does NOT interpret** the meaning of verses - **Does NOT modify** any book content - **Does NOT represent** any particular sampradāya's interpretation - **Does NOT engage** with debates about book editions or changes - **Is NOT connected** to any textual criticism or editorial choices ### What This Tool IS The Sanskrit Script Teacher is: - **A pronunciation aid** based on standard Sanskrit phonology - **A learning tool** for those unfamiliar with Devanāgarī - **Completely transparent** - the underlying text is unchanged - **Academically standard** - uses IAST and Pāṇinian phonology - **Politically neutral** - Sanskrit grammar is not a matter of opinion --- ## Independence from Book Content This is an important clarification: > **The Script Teacher operates on the display layer only. It reads the Devanāgarī characters that exist in the source files and provides pronunciation guidance. It does not know, care about, or interact with any editorial decisions about book content.** The tool would work identically on: - A 1972 first edition - A current BBT edition - A manuscript from 500 years ago - Any Devanāgarī text whatsoever Sanskrit phonology is the same regardless of what words are being pronounced. The letter क is always "ka" whether it appears in the Bhagavad-gītā, a shopping list, or a children's book. --- ## Technical Implementation Details ### Files Involved | File | Purpose | |------|---------| | `publish.js` | Contains the ScriptTeacher module | | `publish.css` | Styling for tooltips and highlights | ### Data Structures ```javascript // Syllable object { dev: "धर्म", // Devanāgarī text iast: "dharma", // IAST transliteration type: "syllable", // syllable | vowel | avagraha | punct id: "sk-0" // Unique identifier } // Stored in Map for O(1) lookup sylMap.set(id, syllable); ``` ### Performance Considerations - Parsing happens once per page load - Syllables cached in Map for instant tooltip lookup - No network requests - all data is local - Minimal DOM manipulation during autoplay --- ## Usage 1. **Enable**: Click the "अ" button in the toolbar (or use keyboard shortcut) 2. **Hover**: Move mouse over any syllable to see pronunciation 3. **Autoplay**: Click play button to hear the verse rhythm 4. **Speed**: Choose Slow (learning), Normal (recitation), or Fast --- ## Credits The Script Teacher implementation draws on: - Standard IAST transliteration conventions - Pāṇinian phonological classification - Traditional Sanskrit prosody (chandas-śāstra) - Unicode Consortium's Devanāgarī specification --- *This tool is offered as a service to those learning to read Sanskrit. It makes no claims beyond phonetic accuracy and welcomes corrections from qualified Sanskrit scholars.*