-2

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.

Shaun Roselt
  • 1,650
  • 5
  • 18
  • 44

1 Answers1

3

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:

  1. use SpEnumTokens() to enumerate available voices until you find one you want.

  2. use SpFindBestToken() to find a voice that matches various criteria you specify.

  3. use SpCreateNewToken() or related function if you know the specific voice you want to use.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • 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
  • 2
    `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