Skip to content

Commit

Permalink
Fixed DataPreprocess bug, Added en-US lengcode in Dataprocess
Browse files Browse the repository at this point in the history
  • Loading branch information
EX3exp committed Sep 26, 2024
1 parent 5c5a1f1 commit c4683c6
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public override string ConvertToIPA(string phoneme, bool isFirstPhoneme)
}
}
string res = string.Join("\t", IPA);
//Log.Debug($"Converted {phoneme} to {res}");
Log.Debug($"Converted {phoneme} to {res}");
return res;
}
}
Expand Down
22 changes: 11 additions & 11 deletions Mirivoice/Mirivoice.Plugins.Builtin/Phonemizers/BasePhonemizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public async Task<string> ConvertToIPA(string sentence, DispatcherPriority dispa

await Dispatcher.UIThread.InvokeAsync(async () =>
{
IPAPhonemes.Clear();
IPAPhonemes = new string[variatedWords.Length].ToList();
bool divideWord = false;
var wordTasks = variatedWords
.Select(async (word, index) => await Task.Run(()=>
Expand All @@ -114,17 +114,17 @@ await Dispatcher.UIThread.InvokeAsync(async () =>
Log.Error($"[ConvertToIPA: Variated Sentence({words.Length})] - [Sentence length({variatedWords.Length})] mismatch");
if (UseWordDivider && phoneme.Trim() == string.Empty)
{
IPAPhonemes.Add(" ");
IPAPhonemes[index] = " ";
}
else
{
if (index == 0)
{
IPAPhonemes.Add(IPAConverter.ConvertToIPA(phoneme.Trim(), true));
IPAPhonemes[index] = IPAConverter.ConvertToIPA(phoneme.Trim(), true);
}
else
{
IPAPhonemes.Add(IPAConverter.ConvertToIPA(phoneme.Trim(), false));
IPAPhonemes[index] = IPAConverter.ConvertToIPA(phoneme.Trim(), false);
}

}
Expand All @@ -133,17 +133,17 @@ await Dispatcher.UIThread.InvokeAsync(async () =>
{
if (UseWordDivider && phoneme.Trim() == string.Empty)
{
IPAPhonemes.Add(" ");
IPAPhonemes[index] = " ";
}
else
{
if (index == 0)
{
IPAPhonemes.Add(IPAConverter.ConvertToIPA(phoneme.Trim(), true));
IPAPhonemes[index] = IPAConverter.ConvertToIPA(phoneme.Trim(), true);
}
else
{
IPAPhonemes.Add(IPAConverter.ConvertToIPA(phoneme.Trim(), false));
IPAPhonemes[index] = IPAConverter.ConvertToIPA(phoneme.Trim(), false);
}
}
}
Expand Down Expand Up @@ -292,7 +292,7 @@ public async Task GenerateIPAAsync(LineBoxView l, DispatcherPriority dispatcherP

await Dispatcher.UIThread.InvokeAsync(async () =>
{
IPAPhonemes.Clear();
IPAPhonemes = new string[l.MResultsCollection.Count].ToList();

bool divideWord = false;
var phonemeTasks = l.MResultsCollection
Expand All @@ -303,17 +303,17 @@ await Dispatcher.UIThread.InvokeAsync(async () =>

if (UseWordDivider && (phoneme == null || phoneme.Trim() == string.Empty))
{
IPAPhonemes.Add(" ");
IPAPhonemes[index] = " ";
}
else
{
if (index == 0)
{
IPAPhonemes.Add(IPAConverter.ConvertToIPA(phoneme.Trim(), true));
IPAPhonemes[index] = IPAConverter.ConvertToIPA(phoneme.Trim(), true);
}
else
{
IPAPhonemes.Add(IPAConverter.ConvertToIPA(phoneme.Trim(), false));
IPAPhonemes[index] = IPAConverter.ConvertToIPA(phoneme.Trim(), false);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ namespace Mirivoice.Mirivoice.Plugins.Builtin.Phonemizers
public class EnglishUSPhonemizer : BasePhonemizer
{
public override BaseIPAConverter IPAConverter { get; set; } = new EnglishUSIPAConverter();
public override bool UseWordDivider { get; set; } = true;
public override bool UseWordDivider { get; set; } = false;

protected override string[] SplitToWords(string sentence)
{
List<string> words = new List<string>();
StringBuilder sb = new StringBuilder();
int index = 0;
foreach (string word in sentence.Split())
{
char[] charArr = word.ToCharArray();
Expand Down Expand Up @@ -44,8 +45,14 @@ protected override string[] SplitToWords(string sentence)
}

}

words.Add(sb.ToString());
sb.Clear();

++index;
if (index != sentence.Split().Length ) {
words.Add(" ");
}
}
return words.ToArray();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static string WordToArpabet(string word)
{
// use the CMU Pronouncing Dictionary to convert words to ARPAbet
string arpabetRes = cmuDict.CMUDict.TryGetValue(word.ToLower(), out string arpabet) ? arpabet.ToLower() : word;
//Log.Debug($"WordToArpabet: {word} -> {arpabetRes}");
Log.Debug($"WordToArpabet: {word} -> {arpabetRes}");
return arpabetRes;

}
Expand Down
1 change: 1 addition & 0 deletions Mirivoice/Views/DataPreprocessWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<TextBlock Text="{DynamicResource menu.tools.voicerMakingSupport.preprocessor.langCode}" VerticalAlignment="Center" FontSize="15" Margin="10 5 5 5"/>
<ComboBox x:Name="langSelectCombobox" Margin="15 10 5 5" SelectedIndex="0" VerticalAlignment="Center" SelectionChanged="LangChanged">
<ComboBoxItem Content="ko" />
<ComboBoxItem Content="en-US" />
</ComboBox>
</StackPanel>

Expand Down
2 changes: 2 additions & 0 deletions Mirivoice/Views/DataPreprocessWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ BasePhonemizer GetPhonemizerWithIndex()
{
case 0:
return LineBoxViewModel.GetPhonemizer("ko");
case 1:
return LineBoxViewModel.GetPhonemizer("en-US");
default:
return new DefaultPhonemizer();
}
Expand Down

0 comments on commit c4683c6

Please sign in to comment.