User Tools

Site Tools


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:

        speed$ = "<RATE ABSSPEED='"+STR$speed%+"'/>"
        volume$ = "<VOLUME LEVEL='"+STR$volume%+"'/>"
        voice$ = "<VOICE REQUIRED='NAME="+name$+"'/>"
        PROC_callmethod(tts%, "Speak("""+speed$+volume$+voice$+phrase$+""")")

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):

        speed$ = "<RATE ABSSPEED='"+STR$speed%+"'/>"
        volume$ = "<VOLUME LEVEL='"+STR$volume%+"'/>"
        voice$ = "<VOICE OPTIONAL='gender=female'/>"
        PROC_callmethod(tts%, "Speak("""+speed$+volume$+voice$+phrase$+""")")

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

        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$+""")")

Note that this code requires COMLIB (or COMLIBA) version 3.3 or later, as supplied with BBC BASIC for Windows version 5.90a.

This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information
setting_20speech_20parameters.txt · Last modified: 2018/04/15 12:53 by richardrussell