Can I install a custom SAPI voice exclusively with my app that other TTS apps will not have access to?

1.8k views Asked by At

I have developed a TTS (text to speech) app in C# using SAPI 5.x. I would like to license or develop my own speech profile (or voice file) that will exclusively be available to my application.

That is, it will not be installed in the same way regular SAPI voices are installed because I do not want other TTS applications to be able to use the voice AND I do not want users to be able to select the custom voice in their system's control panel.

Is it possible? Currently I use SpeechSynthesizer.SelectVoice("Microsoft Anna"); but what I need is to somehow use the SelectVoice to use my own "private" voice file that gets installed alongside my app.

Thank you for any advice or help on this topic.

2

There are 2 answers

0
Alexandru C. On

Usually SAPI stores information about available TTS voices or ASR languages in the Windows registry (HKEY_CURRENT_USER\Software\Microsoft\Speech).

Other TTS application will get the available voices from the registry, so your voice will be available for them also.

There is no way around this.

Maybe if you write some code to add the voice information in the registry when you start your app and remove it when you close it. But that can be a little ... problematic (with regards to access rights).

0
Eric Brown On

You can, but it will involve some (non-trivial) coding. SAPI locates its objects via Object Tokens, which are COM objects that SAPI uses to manage the interactions between engines and applications.

Microsoft's default implementation of ISpObjectToken uses the registry, but you're under no obligation to use that implementation.

If you had your own custom object token implementation (and, quite often, 3rd party engines provide their own object token implementations) you could create a mapping from your object token to the code & data for your private SR voice. If you don't make this object token public (i.e., you don't register your implementation in the registry as part of DllRegisterServer), then the SAPI control panel won't be able to create any instances of your object token, so it will not appear anywhere outside your application.