Download cpp/src/g2p.h from RL10x/tiny-voca-hindi: direct link, hf CLI and curl.
- Browser
- Download file 1.47 kB
-
https://huggingface.co/RL10x/tiny-voca-hindi/resolve/main/cpp/src/g2p.h
- Command line
-
hf download hf://RL10x/tiny-voca-hindi/cpp/src/g2p.h
-
curl -L -o g2p.h https://huggingface.co/RL10x/tiny-voca-hindi/resolve/main/cpp/src/g2p.h
1.47 kB
| // 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. | |
| struct Phonemized { | |
| std::vector<std::string> symbols; // IPA phones, punctuation, <bos> <eos> <sp> <unk> | |
| std::vector<int32_t> ids; // indices into the model's symbol table | |
| std::vector<int32_t> 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<std::string>& symbols); | |
| Phonemized phonemize(const std::string& text) const; // throws NothingToPronounce | |
| private: | |
| std::vector<std::string> symbols_; | |
| int id_of(const std::string& s) const; | |
| }; | |
| std::string normalize_text(const std::string& text); // text.normalize_text | |
| std::vector<std::string> split_sentences(const std::string& text); // infer.sentences | |
| std::string finished(const std::string& text); // infer.finished | |
| std::vector<std::string> shorter(const std::string& text); // infer.shorter | |