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

Added Greek resources and ssml spelling when speaking a single letter word #30

Open
wants to merge 2 commits into
base: dotnet5
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions BabySmash.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<None Update="Resources\Strings\el-GR.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Resources\Strings\ru-RU.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
16 changes: 14 additions & 2 deletions Controller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -400,10 +400,11 @@ private class ThreadedSpeak
{
private string Word = null;
SpeechSynthesizer SpeechSynth = new SpeechSynthesizer();
CultureInfo keyboardLanguage;
public ThreadedSpeak(string Word)
{
this.Word = Word;
CultureInfo keyboardLanguage = System.Windows.Forms.InputLanguage.CurrentInputLanguage.Culture;
keyboardLanguage = System.Windows.Forms.InputLanguage.CurrentInputLanguage.Culture;
InstalledVoice neededVoice = this.SpeechSynth.GetInstalledVoices(keyboardLanguage).FirstOrDefault();
if (neededVoice == null)
{
Expand Down Expand Up @@ -440,7 +441,18 @@ private void Start()
{
try
{
SpeechSynth.Speak(Word);
if(Word.Length > 1)
{
SpeechSynth.Speak(Word);
}
else
{
//This ssml is needed for single letters to support better spelling in non-English languages.
//E.g. without this, the Greek letter 'K' (Κάππα / Kappa) is spoken by the synth as 'Mr.' (Κύριος) as in 'Mr. Scott' (κ. Σκοτ)
SpeechSynth.SpeakSsml($"<speak version=\"1.0\" xmlns=\"http://www.w3.org/2001/10/synthesis\" xml:lang=\"{keyboardLanguage.Name}\">" +
$"<say-as interpret-as=\"characters\">{Word}</say-as>" +
$"</speak>");
}
}
catch (Exception e)
{
Expand Down
21 changes: 21 additions & 0 deletions Resources/Strings/el-GR.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"Circle": "Κυκλάκι",
"Oval": "Οβάλ",
"Rectangle": "Ορθογώνιο",
"Hexagon": "Εξάγωνο",
"Trapezoid": "Τραπέζιο",
"Star": "Αστέρι",
"Square": "Τετράγωνο",
"Triangle": "Τρίγωνο",
"Heart": "Καρδιά",

"Red": "Κόκκινο",
"Blue": "Μπλέ",
"Yellow": "Κίτρινο",
"Green": "Πράσινο",
"Purple": "Μωβ",
"Pink": "Ροζ",
"Orange": "Πορτοκαλί",
"Tan": "Καφέ",
"Gray": "Γκρι"
}