Solved Error when trying to speak.

Gasman

Enthusiastic Amateur
Local time
Today, 16:51
Joined
Sep 21, 2011
Messages
15,353
Hi all,
From a link posted to https://nolongerset.com/speak/#commento-login-box-container

I thought I would give it a try, as no references required.

However when I do, I get an error on Set Vox.Voice = Vox.GetVoices("Gender = " & Gender).Item(0)
Err.Number: -2147200967
Err.Description: Method 'Item' of object 'ISpeechObjectTokens' failed

My audio is working fine. Does anyone have an idea as to why it is not working for me please?

In speech properties, it will read out the text in a female voice.
1726679081843.png
 
You can set a reference to "Microsoft Speech Object Library" to get more info in the object browser, and intellisense, and you can then do...
Code:
Dim vox As New SpeechLib.SpVoice

There might not be a male voice on your system. You can try...
Code:
Debug.Print Vox.GetVoices.Count
... to see how many there are.

You could also do this to explicitly set a voice to a member of the list...
Code:
Set Vox.Voice = Vox.GetVoices.Item(1)
 
There might not be a male voice on your system
Doh! :( You hit the nail on the head. When I tested, it was a female voice.
Changing that to Female, it now works.

Thank you @MarkK
 
Does anyone have an idea as to why it is not working for me please?
Is there a male voice installed on your system?

[I just noticed your last update]
Ok, apparently not. You could use this to check explicitly:

Code:
    Dim vox As Object  ' SpeechLib.SpVoice
    Set vox = CreateObject("SAPI.SpVoice")
    Dim allVoices As Object
    Set allVoices = vox.GetVoices
    
    Dim ot As Object ' SpObjectToken
    For Each ot In allVoices
        Debug.Print ot.getAttribute("Gender")
    Next ot
 
I will tomorrow, but I am guessing not.
I have not played around with any voices, so it will only be what Windows installs.
 
Is there a male voice installed on your system?

[I just noticed your last update]
Ok, apparently not. You could use this to check explicitly:

Code:
    Dim vox As Object  ' SpeechLib.SpVoice
    Set vox = CreateObject("SAPI.SpVoice")
    Dim allVoices As Object
    Set allVoices = vox.GetVoices
   
    Dim ot As Object ' SpObjectToken
    For Each ot In allVoices
        Debug.Print ot.getAttribute("Gender")
    Next ot
I have two, but both Female

1726753605601.png
 
I have two, but both Female
That explains the error message you got earlier.
Strange though, I thought David and Zira would always be available by default even if en-US is not your configured Windows language.
 
Well I have not mucked around with theses things, so no idea. :(
 

Users who are viewing this thread

Back
Top Bottom