User Tools

Site Tools


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. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
listing_20available_20voices.txt · Last modified: 2024/01/05 00:22 by 127.0.0.1