• 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
135 (0.04/day)
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
8,334 (1.45/day)
Location
Charleston, SC
System Name Tower of Power / Delliverance
Processor i7 14700K / i9-14900K
Motherboard ASUS ROG Strix Z790-A Gaming WiFi II / Z690
Cooling CM MasterLiquid ML360 Mirror ARGB Close-Loop AIO / Air
Memory CORSAIR - VENGEANCE RGB 32GB (2x16GB) DDR5 7200MHz / DDR5 2x 16gb
Video Card(s) ASUS TUF Gaming GeForce RTX 4070 Ti / GeForce RTX 4080
Storage 4x Samsung 980 Pro 1TB M.2, 2x Crucial 1TB SSD / NVM3 PC801 SK hynix 1TB
Display(s) Samsung 32" Odyssy G5 Gaming 144hz 1440p, 2x LG HDR 32" 60hz 4k / 2x LG HDR 32" 60hz 4k
Case Phantek "400A" / Dell XPS 8960
Audio Device(s) Realtek ALC4080 / Sound Blaster X1
Power Supply Corsair RM Series RM750 / 750w
Mouse Razer Deathadder V3 Hyperspeed Wireless / Glorious Gaming Model O 2 Wireless
Keyboard Glorious GMMK with box-white switches / Keychron K6 pro with blue swithes
VR HMD Quest 3 (512gb) + Rift S + HTC Vive + DK1
Software Windows 11 Pro x64 / Windows 11 Pro x64
Benchmark Scores Yes
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
135 (0.04/day)
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