Skip to content

Commit 3c60c60

Browse files
authored
Fix(csrc/melotts): Fix V-words pronounciation on MeloTTS_en (#3002)
1 parent 23863f6 commit 3c60c60

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

scripts/melo-tts/test.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ def __init__(self, lexion_filename: str, tokens_filename: str):
1515
for line in f:
1616
s, i = line.split()
1717
tokens[s] = int(i)
18+
# Map "v" to "V" token ID (same as post_replace_ph in MeloTTS, only for English models)
19+
# English models have "V" with token ID 14
20+
if tokens.get("V") == 14 and "v" in tokens:
21+
tokens["v"] = tokens["V"]
22+
1823

1924
lexicon = dict()
2025
with open(lexion_filename, encoding="utf-8") as f:

sherpa-onnx/csrc/melo-tts-lexicon.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,12 @@ class MeloTtsLexicon::Impl {
228228
if (!token2id_.count("") && token2id_.count("")) {
229229
token2id_[""] = token2id_[""];
230230
}
231+
232+
// Map 'v' to 'V' token (same as post_replace_ph in MeloTTS)
233+
// Only for English models
234+
if (meta_data_.language == "en" && token2id_.count("V")) {
235+
token2id_["v"] = token2id_["V"];
236+
}
231237
}
232238

233239
void InitLexicon(std::istream &is) {

0 commit comments

Comments
 (0)