Adding a new Language to SpeechSynthesizer - c#

So I'am trying to add a new language, spesifically norwegian, to SpeechSynthesizer, but it doesn't seem to get installed.
Found this:
Add another voice into .NET Speech
(But here the problem is that Czech isn't supported)
I have installed the norwegian pack from here:
http://www.microsoft.com/en-us/download/details.aspx?id=27224
In my code I use this to check if it is installed:
foreach (var voice in speaker.GetInstalledVoices())
{
Console.WriteLine(voice.VoiceInfo.Description);
}
But it only outputs:
Microsoft Zira Desktop - English (United States)
Have checked the text-to-Speech tool were this is also the only option.
Have also tried to log off/log on and restart the computer.
Anyone know how to fix this?

You may need to add a Speech Language to Windows 10 and set your Locale, Country, Windows display language and Speech language so they are all aligned with one of Cortana's supported locale configurations.
To confirm the settings are set correctly:
Open Settings. Select Time& language, and then Region & Language.
Check the Language (set as default) setting for your Windows display language. If your desired language is not available, add your desired language:
Click Add Language.
Select your desired language from the list.
Select the desired locale, which is the language/country combination.
Click on the newly selected locale and select Options.
Under Download language pack, click Download.
Under Speech, click Download.
After the downloads are complete (this could take several minutes), return to the Time & Language settings.
Click on your new language and select Set as Default.
NOTE: IF you changed languages, you must sign out of your account and back in for the new setting to take effect.
Check the Country or region setting. Make sure the country selected corresponds with the Windows display language set in the Language setting.
Return to Settings and Time & language, and then select Speech. Check the Speech language setting, and make sure it’s aligned with the previous settings.
After you have correctly done the above, your language should appear in the SpeechSynthesizer.AllVoices collection. You should then be able to assign this voice to your SpeechSynthesizer instance's Voice property:
private async void SpeakText(MediaElement audioPlayer, string TTS)
{
SpeechSynthesizer ttssynthesizer = new SpeechSynthesizer();
//Set the Voice/Speaker to Spanish
using (var speaker = new SpeechSynthesizer())
{
speaker.Voice = (SpeechSynthesizer.AllVoices.First(x => x.Gender == VoiceGender.Female && x.Language.Contains("ES")) );
ttssynthesizer.Voice = speaker.Voice;
}
SpeechSynthesisStream ttsStream = await ttssynthesizer.SynthesizeTextToStreamAsync(TTS);
audioPlayer.SetSource(ttsStream, "");
}
http://answers.microsoft.com/en-us/windows/forum/windows_10-other_settings/speech-language-in-windows-10-home/3f04bc02-9953-40b1-951c-c1d262fc3f63?auth=1

Related

in Cefsharp.WPF, how should I do spell check for "fi-FI" (Finnish) language?

I have WPF application which launches web apps. I want to have a spell check for the Finnish language. By default spell check for English is there. I have written the below code to add support to the Finnish language.
Cef.UIThreadTaskFactory.StartNew(delegate
{
var browser = (sender as ChromiumWebBrowser);
var requestContext = browser.GetBrowserHost().RequestContext;
requestContext.SetPreference("browser.enable_spellchecking", true, out _);
requestContext.SetPreference("spellcheck.dictionaries", new List<string> { "en-US", "fi-FI" }, out _);
});
When I set this code, there are below problems
Spell check which was earlier working, red underline for incorrect words for the English language is stopped.
Spell check is not working for Finnish language.
I checked "C:\Users<someUser>\AppData\Local\CEF\User Data\Dictionaries", English dictornory got downloaded but not the Finnish.
Does that mean that CEF doesn't support Finnish language, when I try "en-AU", this dictionary got downloaded.
Basically spell check is available for those languages of which dictionary is present, refer https://github.com/cvsuser-chromium/third_party_hunspell_dictionaries
Also, I have asked a question on CEF Forum if we can add missing languages, refer post here - https://magpcss.org/ceforum/viewtopic.php?f=10&t=17852#p46719
For now, there is no support for the Finnish language "fi-FI".

Incorrect date formatting when VB program opened via C#

What's going on:
I maintain a few small .NET applications for a local business. We've got one pair of apps that work in tandem: a "client manager" (C# / .NET 4.? / winforms) and a "label printer" (VB / .NET 2.0 / winforms).
I recently added a "Print Labels" button to the client manager. This opens the label printer & pre-populates the client's name from the client manager. Woohoo!
Unfortunately, only when the label printer is opened this way, dates print out in "dd/MM/yyyy" format, instead of "MM/dd/yyyy".
What I know:
Date is entered via a DateTime winforms input in the label printer that defaults to "Today".
We see the formatting bug whether the default date is left or is manually changed.
We don't send the date over from the client manager.
We use ".ToShortDateString" in the label printer app.
This never happened when opening the label printer by double-clicking the shortcut/EXE.
This only happens on our Windows 7 Panasonic Toughbook.
The date is wrong whether I print to our Dymo label printer or to PDF. (Thanks, #jdweng!)
Per the Task Manager, the label printer runs as the only local user no matter how I load it. (Thanks, #Polyfun!)
The label printer's CurrentCulture and CurrentUICulture are both en-US, no matter how I load it. (Thanks, #Jimi!)
The user profile uses M/d/yyyy via "Control Panel > Region". (Thanks, #Hans Passant!)
Relevant Code
Here's the C# code I'm using in the client manager to open the label printer app (comments added for clarity):
private void btnLabels_Click(object sender, EventArgs e)
{
// Set via a hybrid string/file input in the app's "Options" menu.
string labelAppLocation = Properties.Settings.Default.LabelAppLocation;
if (String.IsNullOrEmpty(labelAppLocation))
{
MessageBox.Show("We're not sure where your label printer app is located! Set this in \"Options >> Manage Lists >> Files\" and try again.");
}
else
{
Process p = new Process();
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = labelAppLocation;
// This class has some formatting helpers for the
// client's name and other demographics we'd like to send later.
LabelArgs newLabelArgs = new LabelArgs();
newLabelArgs.Name = this.clientName.Text;
psi.Arguments = newLabelArgs.ToString();
p.StartInfo = psi;
p.Start();
}
}
And here's the VB code in the label printer where the date value gets added to the label:
Private Sub DrawItemLabel(ByVal e As System.Drawing.Printing.PrintPageEventArgs)
Dim g As Graphics = e.Graphics
'Custom font handler
Dim fonts As New ItemLabelFonts
'...set fonts, set other line items...
' `myDate` comes directly from a DateTime input's `.Value`.
Dim strMidLine As String = myDate.ToShortDateString & " " & myClientID & " " & myCounty
fonts.MiddleFont = ChooseMaxFontForWidth(strMidLine, fonts.MiddleFont, maxWidth, g)
'...do some math for spacing before drawing the label...
g.DrawString(myClientName, fonts.BottomFont, Brushes.Black, 0, bottomTop)
End Sub
What I think:
Maybe Process#Start() is losing the current culture and falling back to a dd/MM/yyyy default somewhere? (Confirmed not from user's "Region" settings)
Maybe .NET 4.x & .NET 2.0 aren't playing nicely?
Maybe the label printer behaves differently when passed arguments and I need to add a user profile or region through those? There's no logic in the form's Load hook to account for this.
What I've tried:
Checking the DateTime input's settings for a region fallback.
Changing my user's regional settings to see if I can "reset" the formatting.
Duplicating the behavior in Windows 10 & Windows XP (with no luck!)
Turning it off & back on again.
Poring over MSDN.
Why could opening an app via new Process().Start(); change its date formatting?
Success! I retargeted the label printer app from .NET 2.0 to .NET 4.0 (matching the client manager app), cleared out new warnings, and rebuilt the app. Running the v4.0 version of the label printer fixes the issue with no obvious side effects.
I should have done this sooner - I expected going from 2.0 to 4.0 to be a big task, but there were no build errors and the only warnings were implicit conversions. None of these affected Date variables, so I'm still unclear why the 2.0 version acted so strangely, but I'm glad to put this bug to bed. I don't intend to write any new .NET 2.0 projects anytime soon!
I think we're missing something for the Region/Date/Timezone format - somewhere hidden.
I've got a Powershell script to set the date to Australian. Here is the code and XML:
https://github.com/averkinderen/Azure/blob/master/101-ServerBuild/AURegion.xml
#Set Windows regional format (date/time etc.) to Australia - this applies to all users
# Set Locale, language etc.
& $env:SystemRoot\System32\control.exe "intl.cpl,,/f:`"C:\temp\AURegion.xml`""
# Set Timezone
& tzutil /s "AUS Eastern Standard Time"
# Set languages/culture
Set-Culture en-AU
$currentlist = Get-WinUserLanguageList
Write-Host "new lang" $currentlist.LanguageTag
Then I searched for an USA version and I found it here: https://poorerleno.blogspot.com/2018/07/remote-patching-1.html?_sm_au_=i7VM8snvHjkLnPvjBJ3vvK7RJCBJt
#Set Windows regional format (date/time etc.) to American - this applies to all users
if (!(test-path c:\temp)) {
New-Item c:\temp -ItemType Directory
}
[xml]$XmlDocument = invoke-webrequest -Uri https://raw.githubusercontent.com/poorleno1/systemlocale/master/USRegion.xml -UseBasicParsing | Select-Object -ExpandProperty content
$XmlDocument.Save("c:\temp\USRegion.xml")
# Set Locale, language etc.
& $env:SystemRoot\System32\control.exe "intl.cpl,,/f:`"C:\temp\USRegion.xml`""
# Set Timezone
& tzutil /s "Central European Standard Time"
# Set languages/culture
Set-Culture en-US
$currentlist = Get-WinUserLanguageList
Write-Host "new lang" $currentlist.LanguageTag

Windows Iot 1709 Language Pack [duplicate]

So I'am trying to add a new language, spesifically norwegian, to SpeechSynthesizer, but it doesn't seem to get installed.
Found this:
Add another voice into .NET Speech
(But here the problem is that Czech isn't supported)
I have installed the norwegian pack from here:
http://www.microsoft.com/en-us/download/details.aspx?id=27224
In my code I use this to check if it is installed:
foreach (var voice in speaker.GetInstalledVoices())
{
Console.WriteLine(voice.VoiceInfo.Description);
}
But it only outputs:
Microsoft Zira Desktop - English (United States)
Have checked the text-to-Speech tool were this is also the only option.
Have also tried to log off/log on and restart the computer.
Anyone know how to fix this?
You may need to add a Speech Language to Windows 10 and set your Locale, Country, Windows display language and Speech language so they are all aligned with one of Cortana's supported locale configurations.
To confirm the settings are set correctly:
Open Settings. Select Time& language, and then Region & Language.
Check the Language (set as default) setting for your Windows display language. If your desired language is not available, add your desired language:
Click Add Language.
Select your desired language from the list.
Select the desired locale, which is the language/country combination.
Click on the newly selected locale and select Options.
Under Download language pack, click Download.
Under Speech, click Download.
After the downloads are complete (this could take several minutes), return to the Time & Language settings.
Click on your new language and select Set as Default.
NOTE: IF you changed languages, you must sign out of your account and back in for the new setting to take effect.
Check the Country or region setting. Make sure the country selected corresponds with the Windows display language set in the Language setting.
Return to Settings and Time & language, and then select Speech. Check the Speech language setting, and make sure it’s aligned with the previous settings.
After you have correctly done the above, your language should appear in the SpeechSynthesizer.AllVoices collection. You should then be able to assign this voice to your SpeechSynthesizer instance's Voice property:
private async void SpeakText(MediaElement audioPlayer, string TTS)
{
SpeechSynthesizer ttssynthesizer = new SpeechSynthesizer();
//Set the Voice/Speaker to Spanish
using (var speaker = new SpeechSynthesizer())
{
speaker.Voice = (SpeechSynthesizer.AllVoices.First(x => x.Gender == VoiceGender.Female && x.Language.Contains("ES")) );
ttssynthesizer.Voice = speaker.Voice;
}
SpeechSynthesisStream ttsStream = await ttssynthesizer.SynthesizeTextToStreamAsync(TTS);
audioPlayer.SetSource(ttsStream, "");
}
http://answers.microsoft.com/en-us/windows/forum/windows_10-other_settings/speech-language-in-windows-10-home/3f04bc02-9953-40b1-951c-c1d262fc3f63?auth=1

How to add a custom word list to inkrecognizer in uwp?

I have developped a uwp app that has a custom user control allowing handwriting recognition of the user input with a stylus into a textbox.
It works fine for common words, however my users often use technical terms and acronyms that are not always recognised or not recognised at all because they are not featured in the language I have set as the default recognizer for my InkRecognizer.
Here is how I set the default Inkrecognizer :
InkRecognizerContainer inkRecognizerContainer = new InkRecognizerContainer();
foreach (InkRecognizer reco in inkRecognizerContainer.GetRecognizers())
{
if (recognizerName == "Reconnaissance d'écriture Microsoft - Français")
{
inkRecognizerContainer.SetDefaultRecognizer(reco);
break;
}
}
And how I get my recognition results :
IReadOnlyList<InkRecognitionResult> recognitionResults = new List<InkRecognitionResult>();
recognitionResults = await inkRecognizerContainer.RecognizeAsync(myInkCanvas.InkPresenter.StrokeContainer, InkRecognitionTarget.All);
foreach (var r in recognitionResults)
{
string result = r.GetTextCandidates()[0];
myTextBox.Text += " "+result;
}
The expected results are generally not contained in the other textcandidates either.
I have read through the msdn documentation of Windows.UI.Input.Inking but haven't found anything useful on this particular topic.
Same goes for the Channel9 videos existing around handwriting recognition and the results that my google-fu have been able to conjure up.
Ideally, I'm looking for something similar to the WordList that existed in Windows.Inking
Is there a way to programatically add a wordlist to the pool of words of an Inkrecognizer or create a custom dictionary for handwriting recognition in a uwp app ?

Is it possible to set the Windows language bar to english or back to the default from a c# application

I have a C# application that needs to set the Windows language bar to english or at least back to the default setting. I know I can set the InputLanguage of my own application but I need to set the input language for Windows in general. This can be done manually using the language bar, but I need a way to do it programmatically. Is there a way to do this?
I ended up doing this:
Process[] apps=Process.GetProcesses();
foreach (Process p in apps)
{
if (p.MainWindowHandle.ToInt32()>0)
{
NativeWin32.SetForegroundWindow(p.MainWindowHandle.ToInt32());
//send control shift 2 to switch the language bar back to english.
System.Windows.Forms.SendKeys.SendWait("^+(2)");
p.Dispose();
}
}
I haven't done this since Windows XP was in it's childhood, so you may want to check if the language support is still based on the same principles. It is all Win32, so they need to be imported for C#.
First, read on MSDN the pages about keyboard input:
http://msdn.microsoft.com/en-us/library/ms645530%28VS.85%29.aspx
GetKeyboardLayoutList tells you what layout are installed
LoadKeyboardLayout loads a new input locale identifer.
ActivateKeyboardLayout sets the current language
A much better approach to this is this:
//change input language to English
InputLanguage currentLang = InputLanguage.CurrentInputLanguage;
InputLanguage newLang = InputLanguage.FromCulture(System.Globalization.CultureInfo.GetCultureInfo("en-US"));
if (newLang == null)
{
MessageBox.Show("The Upload Project function requires the En-US keyboard installed.", "Missing keyboard", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
else
{
InputLanguage.CurrentInputLanguage = newLang;
}
See full post on this: Language Bar change language in c# .NET

Categories

Resources