Jump to content

SAPI Voice Get Voices Method


Recommended Posts

I'm sorry, but I can really use some help. I want to convert this MSDN VB code which does what I need into autoit. I want to list all of the installed voices (e.g. Microsoft Sam, etc.) and then have the user choose which one he wants to use with a larger application I am working on in autoit. Thank you for any help. Here is the VB code:

The Form_Load procedure creates a voice object and displays the names of all available voices in the list box. Select a voice name in the list box and then click Command1. The Command1 procedure sets the voice object's Voice property to the selected name and causes the voice to speak its new name.

    
Option Explicit

Private V As SpeechLib.SpVoice
Private T As SpeechLib.ISpeechObjectToken

Private Sub Command1_Click()
    On Error GoTo EH

    If List1.ListIndex > -1 Then

        ' Set voice object to voice name selected in
        ' list box (new voice speaks its own name):
        Set V.Voice = V.GetVoices().Item(List1.ListIndex)
        V.Speak V.Voice.GetDescription

    Else
        MsgBox "Please select a voice from the list box."
    End If

EH:
    If Err.Number Then ShowErrMsg
End Sub

Private Sub Form_Load()
    On Error GoTo EH

    Dim strVoice As String

    Set V = New SpVoice

    'Get each token in the collection returned by GetVoices
    For Each T In V.GetVoices
        strVoice = T.GetDescription     'The token's name
        List1.AddItem strVoice          'Add to listbox
    Next

EH:
    If Err.Number Then ShowErrMsg
End Sub

Private Sub ShowErrMsg()

    ' Declare identifiers:
    Dim T As String

    T = "Desc: " & Err.Description & vbNewLine
    T = T & "Err #: " & Err.Number
    MsgBox T, vbExclamation, "Run-Time Error"
    End

End Sub

Thank you again.

Link to comment
Share on other sites

This shuold help, too:

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

@coffeeturtle don´t do spam...

BTW... i don´t look to much your VB library but check it this.. maybe is what you want

Sorry, it was a mistake on my part. When I posted the first time my browser simply reloaded a the same page but this time without my text. So I thought it didn't save, and re-typed the whole thing. I just now saw the double posting.

I have posts in both, so I am going to try to see which solution works and then try to close the superfluous posting. Thanks.

Link to comment
Share on other sites

Yes, he hard coded Microsoft Sam as the default option.

Thanks. I need a "picker" probably through a combobox or list... That is the critical step and the only reason I wanted to poll the machine for all installed voices. Windows7 uses Microsoft Anna as the default. If you don't specify a voice, Windows will automatically choose whatever default voice you have installed. The people I am coding for use a few voices and need the ability to choose for different events, etc.

Link to comment
Share on other sites

I just translated the VB example. It would have been better to use

GUICtrlSetData($list,$x ,$Voice.Voice.GetDescription())

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

Thanks. I need a "picker" probably through a combobox or list... That is the critical step and the only reason I wanted to poll the machine for all installed voices. Windows7 uses Microsoft Anna as the default. If you don't specify a voice, Windows will automatically choose whatever default voice you have installed. The people I am coding for use a few voices and need the ability to choose for different events, etc.

Please just run the example. I am crying inside by your statement.
Link to comment
Share on other sites

  • 2 weeks later...

@coffeeturtle don´t do spam...

BTW... i don´t look to much your VB library but check it this.. maybe is what you want /?do=embed' frameborder='0' data-embedContent>

Thank you also monoscout999! That information you linked has helped me as well.

Thank you all!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...