3131namespace wetts {
3232
3333G2pProsody::G2pProsody (const std::string& g2p_prosody_model,
34- const std::string& vocab ,
34+ const std::string& g2p_prosody_vocab ,
3535 const std::string& lexicon_file,
3636 const std::string& pinyin2id,
3737 const std::string& pinyin2phones,
3838 std::shared_ptr<G2pEn> g2p_en)
3939 : g2p_en_(std::move(g2p_en)), model_(g2p_prosody_model) {
40- std::ifstream in (vocab );
40+ std::ifstream in (g2p_prosody_vocab );
4141 std::string line;
4242 int id = 0 ;
4343 while (getline (in, line)) {
44- vocab_ [line] = id;
44+ g2p_vocab_ [line] = id;
4545 id++;
4646 }
4747 lexicon_ = std::make_shared<Lexicon>(lexicon_file);
@@ -61,7 +61,7 @@ void G2pProsody::Tokenize(const std::vector<std::string>& words,
6161 std::vector<int64_t >* token_ids,
6262 std::vector<int >* token_offsets) {
6363 token_ids->clear ();
64- token_ids->emplace_back (vocab_ .at (CLS_));
64+ token_ids->emplace_back (g2p_vocab_ .at (CLS_));
6565 token_offsets->clear ();
6666 int offset = 1 ; // 0 is taken by CLS_
6767 for (const std::string& word : words) {
@@ -71,20 +71,20 @@ void G2pProsody::Tokenize(const std::vector<std::string>& words,
7171 std::vector<std::string> chars;
7272 SplitUTF8StringToChars (word, &chars);
7373 for (const std::string& ch : chars) {
74- token_ids->emplace_back (vocab_ .at (ch));
74+ token_ids->emplace_back (g2p_vocab_ .at (ch));
7575 offset++;
7676 }
7777 } else if (word[0 ] < 128 && std::isalnum (word[0 ])) {
7878 // English or digit word, Convert english word to UNK
79- token_ids->emplace_back (vocab_ .at (UNK_));
79+ token_ids->emplace_back (g2p_vocab_ .at (UNK_));
8080 offset++;
8181 } else {
82- std::string v = vocab_ .find (word) != vocab_ .end () ? word : UNK_;
83- token_ids->emplace_back (vocab_ .at (v));
82+ std::string v = g2p_vocab_ .find (word) != g2p_vocab_ .end () ? word : UNK_;
83+ token_ids->emplace_back (g2p_vocab_ .at (v));
8484 offset++;
8585 }
8686 }
87- token_ids->emplace_back (vocab_ .at (SEP_));
87+ token_ids->emplace_back (g2p_vocab_ .at (SEP_));
8888}
8989
9090void G2pProsody::Forward (const std::vector<std::string>& words,
0 commit comments