-
Notifications
You must be signed in to change notification settings - Fork 22
SAPI Voice Change #8
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
base: main
Are you sure you want to change the base?
Conversation
Prevents Unity crashes if no voice found.
HResult to SPFindBestToken unused.
Adds function to change the voice to the WindowsTTS class when using the Windows SAPI API.
Formatting to match upstream. Should clean up diff.
|
This is amazing. Could you also create a 32Bit version of the compiled DLL? Otherwise this feature would only be available in the 64Bit. Granted, that's probably 99.99% of all users :D but it could lead to some really confusing bug reports |
No problem. I could actually see us being in that 1% that needs 32bit. I've got another update to enable rate changes that I was just cleaning up so I will combine it all into one pull request. |
SAPI Speech Rate ChangeAdds ability to change SAPI speech rate. This is intended for use in public installations where a user cannot configure their preferred rate as they would on their own personal device. Voice Change Method Added to UAP_AccesibilityManagerAdds Voice Change added and Speech Rate method updated in UAP_AudioQueue
Adds Win32 dll to
|
|
Just a note for anyone finding this -- I believe the change still works as advertised (I have to debug an issue on my end where calling SetVoice too early / at the wrong time causes a Unity crash, but hopefully that's minor / on me), but one thing I noticed is that the current solution lacks Unicode support, which causes a string such as 你好 to be interpreted as ä½ å¥½, which of course is useless if fed to SAPI. I'm not great with native plugins and c++ but from my eyes it seems like this is actually a pretty easy fix -- instead of (see https://learn.microsoft.com/en-us/windows/win32/api/stringapiset/nf-stringapiset-multibytetowidechar) I was able to recompile the DLL myself and to a quick test to verify that this seems to get unicode support working ok. If I have some time later this week I might upload that to another fork just so anyone coming here in the future has it on hand. For what it's worth, it is also possible to get different speakers in the MacOS TTS implementation by providing an additional "-v [voicename]" additional argument to the "say" invocation. |
SAPI Voice Change
Adds the ability to change the voice used by the Windows SAPI API to allow the screen reader language to be changed mid-game. An English language voice, like Microsoft David, would not be able to correctly read Spanish content so a Spanish language voice, like Microsoft Sabina, is required. This is intended for use in public installations where a user cannot configure their preferred language as they would on their own personal device. The language can now be changed in-game and be read correctly by the Windows SAPI API. This only works with the Windows SAPI API.
WindowsTTS.cs
Adds
SetVoice(string name)function to WindowsTTS class. This will use the WindowsTTS dll to change the voice used by the Windows SAPI API. Takes the Name attribute of an installed SAPI voice as the parameter. Available names can be found in the registry underHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\Voices\Tokens\[voice]\Attributes.Example
WindowsTTS.SetVoice("Microsoft David Desktop");WindowsTTS.dll
SetVoiceSAPIfunction will now validatecpTokenbefore attempting to callISpVoice::SetVoice(cpToken). This prevents Unity crashes when invalid voice provided. Compiled, updated, dll added to Plugins/x86_x64 directory.