Skip to content

Commit

Permalink
handle invalid oto lines the right way
Browse files Browse the repository at this point in the history
  • Loading branch information
stakira committed Dec 2, 2023
1 parent d5eff8d commit ad0bc4f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
10 changes: 3 additions & 7 deletions OpenUtau.Core/Classic/VoicebankLoader.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
Expand Down Expand Up @@ -341,10 +341,6 @@ public static OtoSet ParseOtoSet(Stream stream, string filePath, Encoding encodi
};
while (!reader.EndOfStream) {
var line = reader.ReadLine().Trim();
if (string.IsNullOrWhiteSpace(line) ) {
trace.lineNumber++;
continue;
}
trace.line = line;
try {
Oto oto = ParseOto(line, trace);
Expand All @@ -366,7 +362,7 @@ public static OtoSet ParseOtoSet(Stream stream, string filePath, Encoding encodi

static void AddAliasForMissingFiles(OtoSet otoSet) {
// Use filename as alias if not in oto.
var knownFiles = otoSet.Otos.Select(oto => oto.Wav).ToHashSet();
var knownFiles = otoSet.Otos.Where(oto => oto.IsValid).Select(oto => oto.Wav).ToHashSet();
var dir = Path.GetDirectoryName(otoSet.File);
foreach (var wav in Directory.EnumerateFiles(dir, "*.wav", SearchOption.TopDirectoryOnly)) {
var file = Path.GetFileName(wav);
Expand All @@ -383,7 +379,7 @@ static void AddAliasForMissingFiles(OtoSet otoSet) {
}

static void CheckWavExist(OtoSet otoSet) {
var wavGroups = otoSet.Otos.GroupBy(oto => oto.Wav);
var wavGroups = otoSet.Otos.Where(oto => oto.IsValid).GroupBy(oto => oto.Wav);
foreach (var group in wavGroups) {
string path = Path.Combine(Path.GetDirectoryName(otoSet.File), group.Key);
if (!File.Exists(path)) {
Expand Down
1 change: 1 addition & 0 deletions OpenUtau.Test/Classic/VoicebankLoaderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public void OtoSetRoundTrip() {
a.wav=a R,500,,,,
!@#$!@#$
aoieu.wav=- a,,,,,
aoieu.wav=a o,,,,,
aoieu.wav=o i,,,,,
aoieu.wav=i e,,100,150,,
Expand Down

0 comments on commit ad0bc4f

Please sign in to comment.