Change the SAPI Microsoft Speech Object Library Voice with Delphi code

Multi tool use
Change the SAPI Microsoft Speech Object Library Voice with Delphi code
I'm using the 'Microsoft Speech Object Library' and I would like to change the default voice through delphi code.
My default voice is a woman speaking. How do I change it to someone else if someone else is available?
I'm using SAPI 5.4 and Delphi XE6.
1 Answer
1
You did not say which version of SAPI you are using, or show the code you are using to invoke SAPI with.
For instance, in SAPI 5, the ISpVoice
interface has a SetVoice()
method, where you pass it a ISpObjectToken
interface for a specific voice. To get the ISpObjectToken
, you can:
ISpVoice
SetVoice()
ISpObjectToken
ISpObjectToken
use SpEnumTokens()
to enumerate available voices until you find one you want.
SpEnumTokens()
use SpFindBestToken()
to find a voice that matches various criteria you specify.
SpFindBestToken()
use SpCreateNewToken()
or related function if you know the specific voice you want to use.
SpCreateNewToken()
I'm using SAPI 5.4 and I haven't written any code yet, because I do not know how to use those code you gave above. I currently only know how to let it speak the text. Using the SPVoice1.speak()
– Shaun Roselt
Oct 23 '14 at 20:45
SPVoice1.Speak()
is code, so obviously you have "written any code". You would simply call SPVoice1.SetVoice()
before calling SPVoice1.Speak()
. You need to learn how to use the functions I mentioned so you can obtain a token for different voices. If you do not call SPVoice1.SetVoice()
, SPVoice1.Speak()
uses whatever default voice is configured in the Windows Control Panel.– Remy Lebeau
Oct 23 '14 at 21:02
SPVoice1.Speak()
SPVoice1.SetVoice()
SPVoice1.Speak()
SPVoice1.SetVoice()
SPVoice1.Speak()
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
msdn.microsoft.com/en-us/library/ee125652.aspx read the documentation and work with the examples
– David Heffernan
Oct 23 '14 at 21:50