// Hindi front end in C++: Devanagari text -> phoneme symbols + nasal flags. Port of tts_hi/tiny_voca/text.py // (normalize_text, _aksharas, _word_phones, chunks, tokenize, phonemize) and the sentence helpers of // tts_hi/tiny_voca/infer.py (sentences, finished, shorter). Checked against Python by tools/g2p_check.cpp. #pragma once #include #include #include #include struct Phonemized { std::vector symbols; // IPA phones, punctuation, std::vector ids; // indices into the model's symbol table std::vector stress; // 1 = nasalized vowel }; class NothingToPronounce : public std::runtime_error { public: using std::runtime_error::runtime_error; }; // symbols: the model's symbol table (GGUF tinyvoca.symbols), in id order. class HindiG2P { public: explicit HindiG2P(const std::vector& symbols); Phonemized phonemize(const std::string& text) const; // throws NothingToPronounce private: std::vector symbols_; int id_of(const std::string& s) const; }; std::string normalize_text(const std::string& text); // text.normalize_text std::vector split_sentences(const std::string& text); // infer.sentences std::string finished(const std::string& text); // infer.finished std::vector shorter(const std::string& text); // infer.shorter