G2P: Removing duplicate phones

This commit is contained in:
Daniel Wolf 2016-12-20 21:19:10 +01:00
parent e415d59c16
commit 07fe549f42
1 changed files with 6 additions and 1 deletions

View File

@ -88,15 +88,20 @@ vector<Phone> wordToPhones(const std::string& word) {
} while (changed);
}
// Remove duplicate phones
vector<Phone> result;
Phone lastPhone = Phone::Noise;
for (wchar_t c : wideWord) {
Phone phone = charToPhone(c);
if (phone == Phone::Noise) {
logging::errorFormat("G2P error determining pronunciation for '{}': Character '{}' is not a recognized phone shorthand.",
word, static_cast<char>(c));
} else {
}
if (phone != lastPhone) {
result.push_back(phone);
}
lastPhone = phone;
}
return result;
}