Hi Dave,

    Below is what I use inside my program for making Sapi wav
files and such. Yes, all can be done on the fly using the global variables
below. It has to be an XML command to be getting all options in Sapi.
    There are other commands as well, Noun, Verb and may more to get a
change in voice, but all are XML commands; see below functions and 
procedures.
    I wrap all 3 major ones in one function and gets inserted around a given
text for it to be spoken differently.
    Note that they have to be in text format and not numeric, so different
variables to accomplish that but don't have to be if someone were to use
CStr instead.
    After the 2 functions and 2 procedures I use below there is the last 
properties of my Sapi class that use the other, or all the Sapi values 
inside of the Sapi text to speech.

Sapi Global Settings:
Dim ttsEnabled, ttsFileStreamEnabled: ttsEnabled = True:
ttsFileStreamEnabled = True
Dim ttsVoiceNum, ttsVolume, ttsRate, ttsPitch, ttsAudioFormat
ttsVoiceNum = 0: ttsVolume = 100: ttsRate = 0: ttsPitch = 0: ttsAudioFormat
= 35 '44K 16 bit Stereo.
Dim xmlVolume, xmlRate, xmlPitch
xmlVolume = "100": xmlRate = "0": xmlPitch = "0"
Dim myTtsEngine: Set myTtsEngine = Nothing
Dim myTtsFileStream: Set myTtsFileStream = Nothing
Set myTtsEngine = CreateObject( "Sapi.SpVoice")
If myTtsEngine Is Nothing Then
 ttsEnabled = False
Else
 Set myTtsFileStream = CreateObject( "Sapi.SpFileStream")
 If myTtsFileStream Is Nothing Then
  ttsFileStreamEnabled = False
 End If
End If
Function GetTtsXml( txt)
 GetTtsXml =  "<volume level=""" & xmlVolume & """><rate absspeed=""" &
xmlRate & """><pitch absmiddle=""" & xmlPitch & """>" & txt &
"</pitch></rate></volume>"
End Function



Function GetVoiceNameByNum( num)
 GetVoiceNameByNum = myTtsEngine.GetVoices.Item( num).GetDescription
End Function

Sub SetVoiceByNum( num)
 Set myTtsEngine.voice = myTtsEngine.GetVoices.Item( num)
End Sub

Sub SetVoiceByName( name)
 name = LCase( name)
 for i = 0 to myTtsEngine.GetVoices.Count -1
  If InStr( LCase( getVoiceNameByNum( i)), name) Then
   SetVoiceByNum( i)
  End If
 next
End Sub

Sapi Class Voice XML Settings:

    Public Property Get addXmlVolume( txt, vol)
        addXmlVolume = "<volume level=""" & CSTR( vol) & """>" & txt & 
"</volume>"
    End Property

    Public Property Get addXmlRate( txt, rat)
        addXmlRate = "<rate absspeed=""" & CSTR( rat) & """>" & txt & 
"</rate>"
    End Property

    Public Property Get addXmlPitch( txt, pit)
        addXmlPitch = "<pitch absmiddle=""" & CSTR( pit) & """>" & txt & 
"</pitch>"
    End Property

    Public Property Get addXmlEmphasis( txt)
        addXmlEmphasis = "<emph>" & txt & "</emph>"
    End Property

    Public Property Get addXmlSpell( txt)
        addXmlSpell = "<spell>" & txt & "</spell>"
    End Property

    Public Property Get addXmlSilence( msSec)
        addXmlSilence = "<silence msec=""" & CStr( msSec) & """/>"
    End Property

Public Property Get addXmlNoun( txt)
addXmlNoun = "<partofsp part=""noun"">" & txt & "</partofsp>"
End Property

Public Property Get addXmlVerb( txt)
addXmlVerb = "<partofsp part=""verb"">" & txt & "</partofsp>"
End Property

Public Property Get addXmlInterject( txt)
addXmlInterject = "<partofsp part=""interjection"">" & txt & "</partofsp>"
End Property

Public Property Get addXmlModify( txt)
addXmlModify = "<partofsp part=""modifier"">" & txt & "</partofsp>"
End Property

Public Property Get addXmlFunction( txt)
addXmlFunction = "<partofsp part=""function"">" & txt & "</partofsp>"
End Property

Public Property Get addXmlUnknown( txt)
addXmlUnknown = "<partofsp part=""unknown"">" & txt & "</partofsp>"
End Property
End Class

Sent: Friday, July 15, 2011 11:04 AM
Subject: Re: voice parameters


Well, for one thing here, is if you use things like SAPI voices. Qute a
number of these, if not all, have no tone - and many not even a pitch -
setting. So for all of those, your app might have little effect, the way you
describe it.

I know, many claim you can't switch voices on the fly. Not fully sure about
it. TextAloud, a document reading software, is switching sapi voices with no
lack in time. And has been doing so for years. Might be the way they handle
the voices, as compared to the way WE does the job.

You idea of different voice settings for different info, is a pretty good
one, which has been a lack for long time. Smile. Guess, Eloquence and
DecTalk will be the two dedicated voices to handle, then you have the
USB/Serial ones (of which I do not know too much under Windows), and then
you would pretty much have to deal with the box of SAPI voices - far as I
know. Surprising few SAPI voices are produced with too much for adjustment,
except from speed. Of course, your app could either slow down or speed up a
bit, or - in case of info that has to stand out - you might want to break
the line/sentence up in single words, sending one and one word by its own
SPEAK command.
    This,
    Would,
    Make,
    The,
    Line,
    Stand,
    Out,
    a,
    Bit,
    More.

Hope you find a way, since this sure could be useful in quite a few cases.

----- Original Message ----- 
From: "Chip Orange" <[email protected]>
To: <[email protected]>
Sent: Friday, July 15, 2011 2:09 AM
Subject: voice parameters


> Hi all,
>
> I've been working with an app which has different voice settings to convey
> different information (optionally).
>
> I don't want just to allow the user to edit all the voice parameters
> (although I will eventually), but I'd like to come up with reasonably good
> guesses as to what would make a different sounding voice for any number of
> situations (so the user wouldn't have to do any setup work if they didn't
> want to).
>
> I've found varying the tone, which changes what we would call the voice,
> to
> be the best way of achieving this (better than adjusting the pitch; it
> yields voices which are more distinguishable from one another and still
> understandable).
>
> Unfortunately, I think you have no way of knowing what tone values you
> assign will yield a change in the voice.  For Eloquence, I think it's tone
> values of "I" through "M", and for DEC-Talk Access32 it's "H" through "P"
> (I think).
>
> That unfortunately is all I know, and if the user is using some other
> synthesizer, then my app will fail.  So, I was wondering if people who use
> other synthesizers would send me the range of tone settings for their
> particular model of synthesizer which yield different voices?
>
> I'd be glad eventually to publish this as a class so others can benefit.
> Steve has already started me off with nice code for a class which makes it
> easy to switch between various grouped values, and to store them as a
> voice
> "specification".
>
> Just an FYI, I believe you can't switch synthesizers on the fly, the way
> you
> can adjust the tone setting, because you'll get simultaneous speech from
> both, or the switch doesn't happen exactly when you need it to (something
> like that), so adjusting the tone/pitch of your currently selected synth
> is
> the only way I know to deal with this need in general.  I'd be glad to
> hear
> differently though.
>
> thanks for any help.
>
> Chip
>
>
>
>

Reply via email to