User Tools

Site Tools


Command disabled: register
listing_20available_20voices

Listing available voices

by Richard Russell, October 2008

The supplied example program SPEAK.BBC provides the capability of choosing the 'voice' to be used (for example Microsoft Sam or Microsoft Mary), however you need to know in advance which voices are available; if you select one which isn't available it won't work. This is a particular problem given that the available voices may differ between versions of Windows, for example Windows Vista may only have Microsoft Anna which isn't usually available on other versions of Windows.

The code below lists the available voices (it uses SAPI5, typically installed on Windows 2000, XP and Vista and later):

        INSTALL @lib$+"COMLIBA"
 
        ON ERROR ON ERROR OFF : PROC_comexit : PRINT 'REPORT$ : END
        ON CLOSE PROC_comexit : QUIT
 
        PROC_cominit
 
        tts% = FN_createobject("SAPI.SpVoice")
        nvoices% = FN_getvalueint(tts%,"GetVoices.Count")
        DIM voice$(nvoices%-1)
        FOR n% = 0 TO nvoices%-1
          voice$(n%) = FN_getvaluestr(tts%,"GetVoices.Item("+STR$n%+").GetDescription")
          PRINT voice$(n%)
        NEXT
        PROC_releaseobject(tts%)
 
        PROC_comexit

You can of course use the returned list of voices in other ways, such as presenting them to the user in a List Box, or selecting one according to a set of preferences.

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
listing_20available_20voices.txt · Last modified: 2018/04/15 12:51 by richardrussell