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
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".
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
I've localized my App in two languages (English and German) with the MulitlingualAppToolkit 4.0. English is the base language, while german is a translation based on the english one.
The translations are stored as resw-file inside folder "strings.en" and "strings.de".
In App.xaml.cs App() I set the culture like this:
Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = GetCurrentCulture();
CultureInfo.CurrentUICulture = GetCurrentCulture();
private CultureInfo GetCurrentCulture()
{
var cultureName = new DateTimeFormatter("longdate", new[] {"US"}).ResolvedLanguage;
return new CultureInfo(cultureName);
}
(I got this quiet weird way to the regional-culture in Windows 10 from this article https://www.pedrolamas.com/2015/11/02/cultureinfo-changes-in-uwp/ since I recognized that CultureInfo.CurrentCulture and CultureInfo.CurrentUICulture are always "en-EN" no matter what i configurate in my machines regional- and language-settings)
To check if PrimaryLanguageOverride works as expected, I added a TextBox by the name of tbTest on my first Page and a button linkt to this event:
private void Button_Click(object sender, RoutedEventArgs e)
{
Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = tbTest.Text;
Frame.Navigate(this.GetType(), 0);
System.IO.File.AppendAllText(System.IO.Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "PrimaryLanguageOverride.txt"),
DateTime.Now + " - Actual PrimaryLanguageOverride:\n " + WIndows.Globalization.ApplicationLanguages.PrimaryLanguageOverride);
}
catch(Exception ex) { Helper.Log.LogUnhandledError(ex); }
}
Now comes the weird stuff:
When Debugging, or executing the App from my Development-Machine, everything works as expected, but when I make an appx-bundle and install it on another (Windows10-Desktop) device, the App does not recognize the its Language.
In my situation, the device is set to german, regional as well as its language. Also when using the test-procedure, it defenetively gets the string I set , as long as it's a valid culture-name, e.g.: "en-EN", "en-US", "de-DE", "de", "en" (all of these are working fine on my development machine) if it's an invalid string, I get an exception, with a log-entry in my unhandled-error-log. It refresh the Page, and even writes the new-set language in my PrimaryLanguageOverride-Log, but it doesn't change any text I did translate.
So my question is, is this a common Issue (since I recognized in UWP/Win10 the culture-system is a little messed up) or do I use the wrong procedure to override the App-Culture?
This is an issue with AppXBundling. When Installing bundles, it checks with the current OS for the installed Language packs and copies the relevant language resources from the bundle and omits the other language files. The objective of a single bundle is to copy necessary resources and build the application and therefore the languages which are not in the system are considered irrelevant. As a fix you could stop generating single bundles and create package for each CPU architecture. Check this for more info
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
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