------------------------------
Note: The Text-To-Speech examples in this post require the standard COM library. These examples will work on AutoHotkey Basic and the ANSI version of AutoHotkey_L.
Text-To-Speech examples that use the built-in COM objects in AutoHotkey_L can be found here:
http://www.autohotkey.com/forum/viewtopic.php?t=83162
------------------------------
Introduction
Since the release of the
COM Standard Library in 2007 (known earlier as
CoHelper or
COM Helper), I've always assumed that I would find some need to dig into the library and figure it out. Well, the "must have" requirement never materialized but I recently discovered that I could use the library for a Text-To-Speech feature I was adding to a for-fun project so... I set about to figure out how to use
COM Standard Library for Text-To-Speech.
In short, the experience has been exhausting. I've spent much of my free time over that last couple of weeks doing research (mostly on
msdn) and writing trial-and-error code. My progress varied. I would make a big breakthrough one day and then I would get stuck on something that I couldn't figure out for a day or two.
The good news is that I've uncovered a lot of good stuff. The bad news is that I've barely scratched the
COM Standard Library behemoth. Of the ~58 functions available in the libary, I've used 7. For most of the basic Text-To-Speech operations, you only need 4.
To help in the research and testing phase of this campaign, I created several example/proof-of-concept scripts. I thought others might benefit from this effort so I cleaned up the scripts a bit and I'm posting them here for your review.
Examples
There are currently four example scripts:
- Single Instance. This script attempts to duplicate most of the functionality of the TTSApp demo that is provided with the Microsoft Speech SDK 5.1. See the Issues/Considerations section for additional information.
- Multiple Instances. This script demonstrates the use of multiple SpVoice instances.
- Wait Until Done. This script demonstrates a number of techniques for monitoring the end of a SpVoice stream.
- Raw Dump. This is the first script that I wrote to figure out how to do all of the Text-To-Speech stuff via COM. It's not pretty but it includes almost everything that can be done with the SpVoice object. Use a debugger (I use DebugView) to see all of the values.
Screenshots

The CodeThe pertinent files are included in this archive:
RequirementsThese scripts use the
COM Standard Library. In addition, the
Microsoft Speech SDK 5.1 must be installed if using any Windows version earlier than Windows XP. See the
References section for more information.
Issues/ConsiderationsA few considerations:
- Limited Testing. Although these scripts should work on most Windows versions (Windows 98+), I was only able to test using Windows XP. In addition, I only have one audio output (my sound card), so I was unable to test using an alternate audio output.
- Animation. The Example1GUI script includes animation. Although the animation is fairly accurate, I was unable to completely remove the flickering. It's annoying, I know. Live with it. Also, Drugwash reports that the animation does not work on Windows 98 because the OS does not support transparent icons. Sorry 'bout that.
References
Final Thoughts
I'm not an expert on this topic. Not even close. These examples were written by trial-and-error and by extracting syntax and ideas from some of the scripts that have been posted on the AutoHotkey forum and from the example code released with the Microsoft Speech SDK 5.1. If I've made any logic or code blunders (major or minor), I'm hoping that someone will be kind enough to bring it to my attention. I hope to benefit from your experience.
I hope that someone can make use of this information.
---------------------------------------------------------------------------
Release Notes
v0.1Original release.
v0.2Minor improvements.