• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

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

Joined
Jan 13, 2015
Messages
94 (0.07/day)
Likes
10
#1
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:

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

Moderato®™
Staff member
Joined
Apr 16, 2009
Messages
6,798 (1.96/day)
Likes
4,091
Location
Charleston, SC
System Name Sechs / EyeSeven
Processor i7 5820k @ 4.5ghz / i7 2600k @ 4.0Ghz
Motherboard X99S GAMING 7 / ASRock Z68 Extreme3 Gen3
Cooling CORSAIR Hydro Series H100i Extreme / Stock cooler... H50 leaked!..
Memory G.Skill DDR4 2800 16GB 4x4GB / G.Skill DDR3 1600 8gb 2x4GB
Video Card(s) PNY Quadro K2000 / MSI GTX 970 GAMING 4Gb
Storage Samsung 850 PRO 256GB SSD /Intel 240gb, corsair 120gb SSD, 3x 1 tb s storage
Display(s) 2x Acer G276HL 27" 1080p / 3x Acer 22" Nvidia surround
Case Phanteks “Enthoo Pro series”/ Cooler Master Storm Scout
Audio Device(s) Azalia Realtek ALC1150 / SB X-Fi Gamer
Power Supply Corsair CXM CX600M / Corsair 600w
Mouse Razer DeathAdder Chroma / Razer DeathAdder
Keyboard Razer BlackWidow Ultimate /
Software Windows 10 Pro x64 / Windows 10 Pro x64
#2
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.

Code:
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!"
 
Last edited:
Joined
Jan 13, 2015
Messages
94 (0.07/day)
Likes
10
#3
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:
Code:
set voice.Voice = voice.GetVoices.Item(i)
I found the code that returns the number of available text to speech voices via a vbscript:
Code:
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?
 
Top