Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Syllable Word Duration Mapper

Estimate the spoken duration of Hindi, English, and Hinglish (code-mixed) text from syllable counts alone — no audio, no TTS call required. Useful as a fast, offline proxy for how long a sentence will take to speak, e.g. for pacing voice-bot scripts or sanity-checking TTS output length.

How it works

  1. Language detection per word — each whitespace-separated token is classified as Hindi or English by checking for Devanagari Unicode characters (ॿ).
  2. Syllable counting
    • n_syllable_hindi: counts Devanagari grapheme clusters (treating a consonant + halant/virama + following consonant as one cluster, per this approach).
    • n_syllable_english: a regex-based heuristic syllable counter (vowel runs, with exception/correction rules for silent e, -ely, -es/-ed, etc.), adapted from this approach.
  3. Duration mapping — each syllable count is scaled by an empirically fit per-language seconds-per-syllable constant (Hindi: 0.18034... * 1.05, English: 0.2807928174616981) to produce an estimated duration in seconds.
  4. Sentence aggregation — punctuation is stripped, the sentence is split into words, and each word's estimated duration is summed to give a total sentence duration.

Contents

  • alignment_v0.ipynb — the current (v0) implementation and worked examples, including a mixed Hindi/English sentence.

Usage

Open the notebook and run all cells (only standard library modules — unicodedata, re, time — are used, no extra dependencies needed beyond Jupyter itself):

pip install jupyter
jupyter notebook alignment_v0.ipynb

Example:

text = "अगर आप आज payment नहीं करते तो हम legal action initiate करने के लिए बाध्य होंगे।"
# -> per-word syllable/duration breakdown + total estimated duration in seconds

Calibration

The per-syllable duration constants were fit against reference audio timings for representative Hindi, English, and Hinglish sentences (see the commented example durations in the notebook). Accuracy will vary with speaking rate, so treat outputs as an approximation rather than an exact duration.

Status

Early-stage / experimental (v0). Known limitations:

  • English syllable counting is a heuristic and will mis-count some words.
  • Hindi/English detection is per-word and purely script-based, so transliterated Hindi written in Latin script is treated as English.
  • Calibration constants are based on a small sample of sentences.

About

Estimate spoken duration of Hindi, English, and Hinglish text from syllable counts - a fast, offline proxy for TTS/voice-bot script timing

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages