SAPI - How can I detect the users default Language ID (langid)?

Started by Nordwind64, June 21, 2006, 07:07:32 PM

Previous topic - Next topic

Nordwind64

Hi!

SAPI - How can I detect the users default Language ID (langid)?

Best regards,
Nordwind
Greetings, Nordwind.
Windows 7 (64Bit), JWASM/PoLink

P1

Win32API offers:
GetSystemDefaultLangID
GetUserDefaultLangID

Good all the way back to W95.

Regards,  P1  :8)

Nordwind64

Hi P1,

sorry, I'm speaking about SAPI stuff. Text2Speech and such things...
Greetings, Nordwind.
Windows 7 (64Bit), JWASM/PoLink

P1

A User is A User is A User.

So how is a user's langid for the written part of the OS, going to be different than the spoken part of the text of the OS?

How is this any different than the screen readers for the blind work?

Just watch out for Hex vs. Decimal.

Regards,  P1  :8)

Nordwind64

Hi.

QuoteSo how is a user's langid for the written part of the OS, going to be different than the spoken part of the text of the OS?
How is this any different than the screen readers for the blind work?

Yes, sorry it is. I'm a german user, but MS Sam is the default speech in my system. The ID is 409h. To use a german speech, I had to install the german speech files. I must now detect, if the user had installed the german files or not. Thats not possible with GetSystemDefaultLangID/GetUserDefaultLangID, what only gives me 407h. Even, if MS Sam is the default users speech.

Sorry for my bad english...

Best regards,
Nordwind
Greetings, Nordwind.
Windows 7 (64Bit), JWASM/PoLink

P1

From:
Quote from: Nordwind64 on June 21, 2006, 07:07:32 PMSAPI - How can I detect the users default Language ID (langid)?
To:
Quote from: Nordwind64 on June 22, 2006, 04:40:09 AMTo use a german speech, I had to install the german speech files. I must now detect, if the user had installed the german files or not.

So what you really want is to check for installed files for the LangID of the OS?  And you want to know, if there is a SAPI function to enumerate the language options installed?

From a Quick Google search, what you want to do is Enumerate the Voices available to SAPI.  Each Voice will have it's plain text descriptor and it's hex LangID, plus it's options, like male or female, etc..

M$ makes doing this in English as default, so it's fairly easy.  But I understand where your fustration comes from with language options with M$ products.

Regards,  P1  :8)

M$ = Microsoft

Nordwind64

Hi.

QuoteSo what you really want is to check for installed files for the LangID of the OS?  And you want to know, if there is a SAPI function to enumerate the language options installed?

I only want to know the actual LangID from the speech, the user have changed to. The language, the user is listen to in a Text2Speech program :U

QuoteFrom a Quick Google search, what you want to do is Enumerate the Voices available to SAPI.  Each Voice will have it's plain text descriptor and it's hex LangID, plus it's options, like male or female, etc..

Yes, I know. But I don't know, how to get it work. I could get the token with GetVoice, but I cannot read it for informations.
Shit, my English is to bad...

Best regards,
Nordwind
Greetings, Nordwind.
Windows 7 (64Bit), JWASM/PoLink

P1

Quick and dirty is to enumerate the Registry Here:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\VOICES\TOKENS
Note:  I have only English setup, But I had to go through a Voice setup, to have these voices available ( One male, One female ). 

Otherwise, you need to work through developing code from MSDN site:
In both SpEnumTokens and ISpObjectTokenCategory::EnumTokens the following clauses are permitted in the ReqAttrs and OptAttrs strings, separated by semicolons.

When what you want, is not there, then you need to develope a setup routine for those German Languges files and Voice setup.

Regards,  P1  :8)

PS:  Loading German Files does not setup the Voice for you.  I just did and I have no new voices to use.

Nordwind64

QuotePS:  Loading German Files does not setup the Voice for you.  I just did and I have no new voices to use.

Because you must have Microsoft Reader installed...
I will try to use your tips. Thanks!

Best regards,
Nordwind
Greetings, Nordwind.
Windows 7 (64Bit), JWASM/PoLink

Nordwind64

Could not get it working. Ok, in the registry there are tokens for all speeches and languages. But I cannot detect, which ist the one, SAPI talks with...

Sorry, I need help.  :red
Nordwind
Greetings, Nordwind.
Windows 7 (64Bit), JWASM/PoLink

P1

When enumerating the tokens, under the voice name is a sub key of "ATTRIBUTES", under which you will find "Language" and the hex in text value of the LangID. 

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\VOICES\TOKENS\LHMICHAEL\ATTRIBUTES]
"Gender"="Male"
"Language"="409"
"Name"="LH Michael"


I know that some registries entries are language based, so I don't know if it will say any of the above is English Key words or you may adjust for German Key words.

The registry method is going to be quicker to implement, but the SAPI function method, I am sure it's more language independent.

Regards,  P1  :8)

Nordwind64

Hi.

I understand, what you mean. I can get all infos about all installed languages, no problem.
But I cannot see, which language is marked as default! That is, what i want to know...  :P
Greetings, Nordwind.
Windows 7 (64Bit), JWASM/PoLink

P1

[HKEY_CURRENT_USER\Software\Microsoft\Speech\Voices]
"DefaultTokenId"="HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Speech\\Voices\\Tokens\\LHMICHAEL"
"DefaultTTSRate"=dword:00000000


LHMICHAEL is my local name for my default voice.

Regards,  P1  :8)

Nordwind64

 :U

That's it! I only looked in HKEY_LOCAL_MACHINE instead of looking in HKEY_CURRENT_USER.  :dazzled:
Now I can read the default language parameters!

Thank you a lot!   :cheekygreen:

Best regards,
Nordwind
Greetings, Nordwind.
Windows 7 (64Bit), JWASM/PoLink

P1

Ihr Empfang!

Haben Sie ein nettes Wochenende!  :U

Aber ich bin ängstlich Sie haben mehr Arbeit vor Ihnen, als hinter Ihnen.  :eek

Beachtungen,  P1  :8)

PS: Ich habe gedacht, dass ich ein freies Deutsch zu englischem Übersetzer ausprobieren würde.