diff --git a/src/recognition/g2p.cpp b/src/recognition/g2p.cpp index 7014bd9..2765390 100644 --- a/src/recognition/g2p.cpp +++ b/src/recognition/g2p.cpp @@ -88,15 +88,20 @@ vector wordToPhones(const std::string& word) { } while (changed); } + // Remove duplicate phones vector 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(c)); - } else { + } + + if (phone != lastPhone) { result.push_back(phone); } + lastPhone = phone; } return result; }