Getting the current voice

by Richard Russell, March 2013

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

The code below can be used to discover the currently selected voice name:

        voice$ = FN_getvaluestr(tts%, "Voice.GetDescription")

Where tts% is the value returned from “FN_createobject(“Sapi.SpVoice”)”.

Here is a self-contained program illustrating its use:

        INSTALL @lib$+"COMLIBA"
 
        ON ERROR PROC_comexit : PRINT 'REPORT$ : END
        ON CLOSE PROC_comexit : QUIT
        PROC_cominit
 
        tts% = FN_createobject("Sapi.SpVoice")
        IF tts%=0 ERROR 100, "SAPI5 is not available"
 
        voice$ = FN_getvaluestr(tts%, "Voice.GetDescription")
        PRINT voice$
 
        PROC_releaseobject(tts%)
        PROC_comexit
        END