gexgd0419 / NaturalVoiceSAPIAdapter

Make Azure natural TTS voices accessible to any SAPI 5-compatible application.
MIT License
52 stars 4 forks source link

Problem with adjusting what languages of the Edge voices are shown #7

Open TMaestro75 opened 2 weeks ago

TMaestro75 commented 2 weeks ago

Greetings, In the installer, when the box for including the Microsoft Edge voices has been checked, there are two options. You can either show all supported languages or the current display language and American English. It seems that for some applications, there are too many voices or something when I choose to display all supported languages, because not all the voices show up in JAWS for example. Is there no way to customize exactly what languages are available? I checked the registry and searched for some sort of config file, but the only things I found were those two options. I assume that the installer automatically detects your display language and then adds English US, and everything else is basically hard coded. Is there no way of changing this? There are certain languages where I really need a speech synth, but I don't need all of them and the ones I need don't show up in JAWS.

gexgd0419 commented 2 weeks ago

Unfortunately, in the current release version (v0.1), the language selection IS hard-coded to be either display language + English US, or all languages. Adding a mechanism and a UI for selecting languages requires some work, so I didn't do it in the first release, but I do plan to add this feature in a future release.

To figure out the user's current display language, the program uses GetUserPreferredUILanguages(), gets a list of preferred languages, and checks the language of each voice against that list. I thought that a user could have more than one preferred languages in Settings > Language & region, but seems that I was wrong, and only the selected display language will be included in the list.

JAWS does seem to have some limitation on the voice count. I made the voice enumerator enumerate 999 fake voices, and the TTS tester app showed all of them, while JAWS only listed the first about 300 voices. There are currently 318 Edge online voices, so I guess that is the problem. And when I made the enumerator skip the first half of the voice list, the second half (e.g. Portuguese, Russian, Spanish) could be shown correctly in JAWS.

There are also Javanese and Sundanese voices in the Edge online voice list. However, they cannot be used in JAWS and some other apps, because their locale names, jv-ID and su-ID, do not have corresponding locale IDs.

A locale ID is a number that specifies a pair of a language and a sort order. For example, English (US) has a locale ID of 0x0409, and a locale name of en-US. The use of locale IDs has been deprecated, but since SAPI 5 is an old standard, it still requires using locale IDs to represent voice languages, and as a result, languages without locale IDs cannot be used as voice languages.

In the current release version (v0.1), those voices are given invalid locale IDs. Some apps can still work, some apps may show incorrect language names for them, some may just ignore those voices, and some may crash because they aren't prepared for invalid locale IDs. So I guess I need a better way.