Skip to content

Commit

Permalink
Clean up announcement / selection of voices
Browse files Browse the repository at this point in the history
  • Loading branch information
CaffeineAU committed Jul 31, 2017
1 parent 91ce21b commit bb633d1
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 47 deletions.
5 changes: 5 additions & 0 deletions Translator/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ public TTSProvider SelectedEngine
{
selectedEngine = value;
Properties.Settings.Default.LastTTSProvider = SelectedEngine.Name;
if (SelectedEngine.AvailableVoices.Count > 0)
{
SelectedEngine.SelectedVoice = SelectedEngine.AvailableVoices[0];

}
OnPropertyChanged("SelectedEngine");
CheckFolderForVoices();

Expand Down
38 changes: 10 additions & 28 deletions Translator/TTSProvider/AmazonPollyProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,49 +34,37 @@ public AmazonPollyTTSProvider()
{
try
{
//List<Amazon.Polly.Model.Voice> availableVoices = polly.DescribeVoices(new Amazon.Polly.Model.DescribeVoicesRequest()).Voices;
foreach (var v in polly.DescribeVoices(new Amazon.Polly.Model.DescribeVoicesRequest()).Voices)
{
AvailableVoices.Add(new Voice { Name = v.Name, Gender = v.Gender.ToString(), Language = v.LanguageName });
}

//foreach (var item in availableVoices)
//{
// AvailableVoices.Add(new TTSAutomate.Voice { Name = item.Name, Gender = item.Gender, Language = item.LanguageName });
//}
if (Properties.Settings.Default.RememberLanguageSettings && this.Name == Properties.Settings.Default.LastTTSProvider)
if (this.Name == Properties.Settings.Default.LastTTSProvider)
{
SelectedVoice = AvailableVoices.Find(n => n.Name == Properties.Settings.Default.LastTTSVoice);
}
else
{
SelectedVoice = AvailableVoices[0];
if (Properties.Settings.Default.RememberLanguageSettings)
{
SelectedVoice = AvailableVoices.Find(n => n.Name == Properties.Settings.Default.LastTTSVoice);
}
else
{
SelectedVoice = AvailableVoices[0];
}
}
}
catch (Exception Ex)
{
Logger.Log(Ex.ToString());
AvailableVoices.Add(new Voice { Name = "Amazon Polly Voices are Disabled", Language = "en-US", Gender = "None"});
SelectedVoice = AvailableVoices[0];
disabled = true;
}
};
loadVoicesWorker.RunWorkerAsync();

AvailableSpeeds.AddRange(new String[] { "x-slow", "slow", "medium", "fast", "x-fast" });
SelectedDiscreteSpeed = "medium";

AvailableVolumes.AddRange(new String[] { "silent", "x-soft", "soft", "medium", "loud", "x-loud" });
SelectedDiscreteVolume = "medium";
}

public override void DownloadItem(PhraseItem item, string folder)
{
// String SSMLText = String.Format(@"
//<?xml version=""1.0""?>
//<speak xml:lang=""en - US"" onlangfailure=""processorchoice"" xmlns=""http://www.w3.org/2001/10/synthesis"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"">
// {0}
//</speak >
//", item.Phrase.Replace("&", "&amp;"));
String SSMLText = String.Format(@"
<speak>
{0}
Expand Down Expand Up @@ -111,12 +99,6 @@ public override void DownloadItem(PhraseItem item, string folder)

public override void DownloadAndPlayItem(PhraseItem item, string folder)
{
// String SSMLText = String.Format(@"
//<?xml version=""1.0""?>
//<speak xml:lang=""en - US"" onlangfailure=""processorchoice"" xmlns=""http://www.w3.org/2001/10/synthesis"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"">
// {0}
//</speak >
//", item.Phrase.Replace("&", "&amp;"));
String SSMLText = String.Format(@"
<speak>
{0}
Expand Down
15 changes: 9 additions & 6 deletions Translator/TTSProvider/GoogleTTSProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,16 @@ public GoogleTTSProvider()
cultures.AddRange(CultureInfo.GetCultures(CultureTypes.SpecificCultures));
cultures.Sort((x, y) => x.DisplayName.CompareTo(y.DisplayName));
AvailableVoices = cultures.Select(x => new Voice() { Name = x.DisplayName, Language = x.Name }).ToList();
if (Properties.Settings.Default.RememberLanguageSettings && this.Name == Properties.Settings.Default.LastTTSProvider)
if (this.Name == Properties.Settings.Default.LastTTSProvider)
{
SelectedVoice = AvailableVoices.Find(n => n.Name == Properties.Settings.Default.LastTTSVoice);
}
else
{
SelectedVoice = AvailableVoices[0];
if (Properties.Settings.Default.RememberLanguageSettings)
{
SelectedVoice = AvailableVoices.Find(n => n.Name == Properties.Settings.Default.LastTTSVoice);
}
else
{
SelectedVoice = AvailableVoices[0];
}
}

};
Expand Down
16 changes: 9 additions & 7 deletions Translator/TTSProvider/IvonaTTSProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,17 @@ public IvonaTTSProvider()
try
{
AvailableVoices = IvonaListVoices().Voices;
if (Properties.Settings.Default.RememberLanguageSettings && this.Name == Properties.Settings.Default.LastTTSProvider)
if (this.Name == Properties.Settings.Default.LastTTSProvider)
{
SelectedVoice = AvailableVoices.Find(n => n.Name == Properties.Settings.Default.LastTTSVoice);
}
else
{
SelectedVoice = AvailableVoices[0];
if (Properties.Settings.Default.RememberLanguageSettings)
{
SelectedVoice = AvailableVoices.Find(n => n.Name == Properties.Settings.Default.LastTTSVoice);
}
else
{
SelectedVoice = AvailableVoices[0];
}
}

}
catch (Exception Ex)
{
Expand Down
15 changes: 9 additions & 6 deletions Translator/TTSProvider/MicrosoftTTSProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,16 @@ public MicrosoftTTSProvider()
{
AvailableVoices.Add(new Voice { Name = v.Name, Gender = v.Gender.ToString(), Language = v.Culture.Name});
}
if (Properties.Settings.Default.RememberLanguageSettings && this.Name == Properties.Settings.Default.LastTTSProvider)
if (this.Name == Properties.Settings.Default.LastTTSProvider)
{
SelectedVoice = AvailableVoices.Find(n => n.Name == Properties.Settings.Default.LastTTSVoice);
}
else
{
SelectedVoice = AvailableVoices[0];
if (Properties.Settings.Default.RememberLanguageSettings)
{
SelectedVoice = AvailableVoices.Find(n => n.Name == Properties.Settings.Default.LastTTSVoice);
}
else
{
SelectedVoice = AvailableVoices[0];
}
}
}).Start();

Expand Down

0 comments on commit bb633d1

Please sign in to comment.