Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SAPI 5.1, change pitch programmatically, add voices?

1,294 views
Skip to first unread message

Mike S

unread,
Feb 18, 2016, 2:48:49 AM2/18/16
to
I'm doing my first VB6 text to speech program using SAPI version 5.1,
and while you can change the rate and volume while the speech engine is
running, I was wondering if you can change the pitch to make a voice
higher or lower, while the speech engine is running? Also, is there an
additional set of voices that can be downloaded? Right now there are 4
and I'd like to offer more if they're available.
Thanks,
Mike

Mayayana

unread,
Feb 18, 2016, 9:03:16 AM2/18/16
to
On pitch, here's a simple VBS example:

Dim Voice
Set Voice = CreateObject("Sapi.spVoice")

Voice.Speak "Some text here. <PITCH MIDDLE = '5'/> This text is higher
pitch.", 8

Voice.Speak "Some text here. <PITCH MIDDLE = '5'/> This text is higher
pitch.<pitch middle='-8'/> And this text goes lower.", 8

Set Voice = Nothing

There are the basic properties, then there's
XML, which seems to be analogous to RTF
formatting. (Note the 2nd parameter flag needed
to use XML.) The help shows the XML using
closing tags, but that seems to cause
uninformative errors.

If you don't have the help file you may want
to get it. It's fairly complete. The separate SDKs
are no longer available, though. MS now puts
everything into the platform SDK and you have
to pick out the HXS files from that. To convert
the HXS to CHM, see here:

http://www.jsware.net/jsware/hxs2chm.php5

On the voices, I'm not sure. I got Mike and
Mary for XP and find Mary to be a tolerable
voice. You may be able to add those to Vista/7,
but my memory is not fresh on those details.


Mayayana

unread,
Feb 18, 2016, 9:05:53 AM2/18/16
to
Update: On the second sample this seems to work better:

Voice.Speak "Some text here. <PITCH MIDDLE = '5'> This text is higher
pitch.</pitch><pitch middle='-8'/> And this text goes lower.", 8

Maybe it needs closing tags when a new tag is
being used, but rejects them otherwise. I'm not
sure. This is the first time I've tried the XML and
it seems to be finicky.


BillyJ

unread,
Feb 18, 2016, 11:52:28 AM2/18/16
to
Better voices you pay for.

Check out AT&T SAPI voices.

I have Crystal and Mike.
The are acceptable.

I am sure there are more.
Search for SAPI voices.
at&t natural voice sapi5



Mike S

unread,
Feb 18, 2016, 9:15:44 PM2/18/16
to
Thanks Mayahyana,

I saw that in the documentation, I was wondering if there's a way to
change pitch dynamically while the voice engine is running. That would
let the users tune the voice exactly the way they wanted it without
stopping the voice, picking a setting, playing it, repeating the process
until they're satisfied. It's not a big deal but I'd like to make it as
user friendly as possible.

Mike

Mike S

unread,
Feb 18, 2016, 9:18:13 PM2/18/16
to
On 2/18/2016 8:52 AM, BillyJ wrote:
> Crystal and Mike.

Thanks BillyJ,

I'll download them if they're free.
I noticed that Windows 10 has additional voices that have pretty good
quality ratings. When it comes to distributing the program, do you
happen to know whether the program is restricted to using the voices the
user has installed on their system? Or can we bundle voices into the
installation files so they get installed along with the program?

Thanks,
Mike

GS

unread,
Feb 19, 2016, 1:31:29 PM2/19/16
to
I have Lou Gehrig's and so use TTS extensively. AFAIK, all the TTS apps
allow you to change voices, but not during speech!

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion

BillyJ

unread,
Feb 19, 2016, 7:38:08 PM2/19/16
to
3rd party voice are not free, at least none that I know if.
I believe you can distribute the paid voices but best check the 3rd party.

As far as distributing MS voices, I doubt it.

It is always better to have the user select and download from the 3rd
party based on your recommendations for quality. No licensing issues then.


Mike S

unread,
Feb 19, 2016, 8:02:36 PM2/19/16
to
Thanks BillyJ.

Mike S

unread,
Feb 19, 2016, 8:03:10 PM2/19/16
to
On 2/19/2016 10:31 AM, GS wrote:
>> On 2/18/2016 6:05 AM, Mayayana wrote:
>>> Update: On the second sample this seems to work better:
>>>
>>> Voice.Speak "Some text here. <PITCH MIDDLE = '5'> This text is higher
>>> pitch.</pitch><pitch middle='-8'/> And this text goes lower.", 8
>>> Maybe it needs closing tags when a new tag is
>>> being used, but rejects them otherwise. I'm not
>>> sure. This is the first time I've tried the XML and
>>> it seems to be finicky.
>>
>> Thanks Mayahyana,
>>
>> I saw that in the documentation, I was wondering if there's a way to
>> change pitch dynamically while the voice engine is running. That would
>> let the users tune the voice exactly the way they wanted it without
>> stopping the voice, picking a setting, playing it, repeating the
>> process until they're satisfied. It's not a big deal but I'd like to
>> make it as user friendly as possible.
>>
>> Mike
>
> I have Lou Gehrig's and so use TTS extensively. AFAIK, all the TTS apps
> allow you to change voices, but not during speech!

I can change voices on the fly but so far I haven't been able to change
pitch. Thanks.

BillyJ

unread,
Feb 21, 2016, 11:13:37 AM2/21/16
to
To change pitch dynamically try this.

Create a test sentence.
Split at spaces into an array.

Loop on the array and say one word at a time.
Between each word see if the pitch needs to change (slider for user to
select a different pitch) and change it.

May not be really smooth but should accomplish what you need using a
test sentence.

Mike S

unread,
Feb 22, 2016, 8:33:15 PM2/22/16
to
Thanks! That will work fine as a Plan B and is quickly becoming Plan A.
0 new messages