# How do you change the text to speech voice in a (Windows) vbscript?



## grecinos (Mar 27, 2018)

Hey guys,

I'm trying to create a text to speech vbscript.  The problem I'm having is that I can only select between 3 voices.  I have 8 available in Windows 10. 

Here is my code:


```
set voice = CreateObject("SAPI.SpVoice")
set voice.Voice = voice.GetVoices.Item(1)
voice.Rate = 1
voice.Volume = 90
voice.Speak TextMessage
```

I get a vbs error message when I choose a number greater than 2 for the voice.GetVoices.Item(1) parameter. 

Error: 0x80045039
Code: 80045039
Source: (null)

Any suggestions?

TIA,

grecinos


----------



## Mindweaver (Mar 27, 2018)

I believe you have to install the other voices using Speech SDK 5.1.
Don't forget always add your code using the code tag [code][/code]
*EDIT: I installed it to see, but it didn't seem to use any other voices. I did check my installed voices and I only see David, Zira, and Mark. David is Item(0) and Zira is Item(1), but I don't see Mark's Item number.*


```
Option Explicit
Dim Zira, David

'Zira's Voice
Set Zira = CreateObject("SAPI.spVoice")
Set Zira.Voice = Zira.GetVoices.Item(1)
Zira.Rate = 2
Zira.Volume = 70

'David's Voice
Set David = CreateObject("SAPI.spVoice")
Set David.Voice = David.GetVoices.Item(0)
David.Rate = 2
David.Volume = 100

Zira.Speak "My Name is Zira."
David.Speak "My Name is David. It's nice to meet you!"
```


----------



## grecinos (Mar 29, 2018)

I've been doing some research on this topic for about an hour.  All of the tutorials that I've found indicates to use this format in order to change the voice:

```
set voice.Voice = voice.GetVoices.Item(i)
```

I found the code that returns the number of available text to speech voices via a vbscript:

```
voice.GetVoices.Count
```

When I run that line of code, I get "3" as the return value.  I clearly have 8 installed, though.  My intuition is that there must be a way to enable all available voices somewhere in the Windows 10 OS.  Just a guess...

Any thoughts?


----------



## lelvsjtz (May 12, 2018)

Your missing voices are 32bit.
How do I run a VBScript in 32-bit mode on a 64-bit machine?


----------

