Setting+speech+parameters

//by Richard Russell, October 2008//

//**This article is specific to the SAPI5 speech system, typically installed on Windows 2000, XP and Vista**//

When using Windows' built-in speech synthesis capability it is possible to override the default **speed**, **volume** and **voice** parameters with your own preferences. There are two main ways of doing this; the first method (which is used in the supplied example program **SPEAK.BBC**) involves embedding //tags// in the text to be spoken, for example:

code format="bb4w" speed$ = "" volume$ = "" voice$ = "" PROC_callmethod(tts%, "Speak("""+speed$+volume$+voice$+phrase$+""")") code Here **speed%** should be in the range -10 to +10, **volume%** should be in the range 0 to 100 and **name$** should be a voice name such as **Microsoft Mike** (see this article for how to discover the available voices).

As an alternative to specifying a particular voice you can express a preference for a male or female voice (if the choice is available):

code format="bb4w" speed$ = "" volume$ = "" voice$ = "" PROC_callmethod(tts%, "Speak("""+speed$+volume$+voice$+phrase$+""")") code

The second method involves direct calls to the speech system to set the appropriate parameters, for example:

code format="bb4w" PROC_putvalue(tts%, "Rate("+STR$speed%+")") PROC_putvalue(tts%, "Volume("+STR$volume%+")") vobj% = FN_getobject(tts%, "GetVoices(""NAME="+name$+""").Item(0)") PROC_putobject(tts%, "Voice(O vobj%)") PROC_callmethod(tts%, "Speak("""+phrase$+""")") code Note that this code requires **COMLIB** (or **COMLIBA**) version **3.3** or later, as supplied with //BBC BASIC for Windows// version 5.90a.