Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add checks for phoneme definitions in dsdict.yaml #1256

Merged
merged 1 commit into from
Sep 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion OpenUtau.Core/DiffSinger/DiffSingerBasePhonemizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,19 @@ protected bool IsSyllableVowelExtensionNote(Note note) {
/// distribute phonemes to each note inside the group
/// </summary>
List<phonemesPerNote> ProcessWord(Note[] notes, string[] symbols){
//Check if all phonemes are defined in dsdict.yaml (for their types)
foreach (var symbol in symbols) {
if (!g2p.IsValidSymbol(symbol)) {
throw new InvalidDataException(
$"Type definition of symbol \"{symbol}\" not found. Consider adding it to dsdict.yaml (or dsdict-<lang>.yaml) of the phonemizer.");
}
}
var wordPhonemes = new List<phonemesPerNote>{
new phonemesPerNote(-1, notes[0].tone)
};
var dsPhonemes = symbols
.Select((symbol, index) => new dsPhoneme(symbol, GetSpeakerAtIndex(notes[0], index)))
.ToArray();
.ToArray();
var isVowel = dsPhonemes.Select(s => g2p.IsVowel(s.Symbol)).ToArray();
var isGlide = dsPhonemes.Select(s => g2p.IsGlide(s.Symbol)).ToArray();
var nonExtensionNotes = notes.Where(n=>!IsSyllableVowelExtensionNote(n)).ToArray();
Expand Down
9 changes: 9 additions & 0 deletions OpenUtau.Core/DiffSinger/DiffSingerPitch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ public RenderPitchResult Process(RenderPhrase phrase){
var endMs = phrase.notes[^1].endMs + tailMs;
int headFrames = (int)Math.Round(headMs / frameMs);
int tailFrames = (int)Math.Round(tailMs / frameMs);
if (dsConfig.predict_dur || dsConfig.use_note_rest) {
//Check if all phonemes are defined in dsdict.yaml (for their types)
foreach (var phone in phrase.phones) {
if (!g2p.IsValidSymbol(phone.phoneme)) {
throw new InvalidDataException(
$"Type definition of symbol \"{phone.phoneme}\" not found. Consider adding it to dsdict.yaml of the pitch predictor.");
}
}
}
//Linguistic Encoder
var linguisticInputs = new List<NamedOnnxValue>();
var tokens = phrase.phones
Expand Down
9 changes: 9 additions & 0 deletions OpenUtau.Core/DiffSinger/DiffSingerVariance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,15 @@ int PhonemeTokenize(string phoneme){
public VarianceResult Process(RenderPhrase phrase){
int headFrames = (int)Math.Round(headMs / frameMs);
int tailFrames = (int)Math.Round(tailMs / frameMs);
if (dsConfig.predict_dur) {
//Check if all phonemes are defined in dsdict.yaml (for their types)
foreach (var phone in phrase.phones) {
if (!g2p.IsValidSymbol(phone.phoneme)) {
throw new InvalidDataException(
$"Type definition of symbol \"{phone.phoneme}\" not found. Consider adding it to dsdict.yaml of the variance predictor.");
}
}
}
//Linguistic Encoder
var linguisticInputs = new List<NamedOnnxValue>();
var tokens = phrase.phones.Select(p => p.phoneme)
Expand Down
Loading