However, it you want to do anything more complicated, you'll need to add a few more lines of code.

A few Text-To-Speech examples for AutoHotkey v1.1+ have already been published (see the References section below). I decided to update the Text-To-Speech via COM - Examples post that I wrote a few years back because it includes a few advanced features that I haven't seen anyone use yet.

ExamplesThere are currently three 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.

RequirementsThe 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. The animation does not work on Windows 98 because the OS does not support transparent icons. Sorry 'bout that.

References

Microsoft Speech SDK 5.1This software is not necessary if using Windows XP or greater. However, the installation includes two additional voices (Microsoft Mike and Microsoft Mary) so it might be worth the trouble to install it.http://tinyurl.com/yptaoo

SpVoice Interface (SAPI 5.3)A must-have guide to the SpVoice (Text-To-Speech engine) interface. This guide includes a list of all of the SpVoice methods as well as what is needed to call them.http://tinyurl.com/mqngf4

SpVoice (Events) Interface (SAPI 5.3)A must-have guide to the SpVoice Events interface. This guide includes a list of all the SpVoice events as well as all of the parameters that are passed for each event.http://tinyurl.com/lsjq48

Final ThoughtsI'm still a AutoHotkey v1.1+ beginner. 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 suggest to include a no-GUI version to make it easier to find the relevant TTS code.

A couple of thoughts...

Although the Example1GUI script is certainly not ideal for someone who wants to use Text-To-Speech in a linear and/or non-interactive fashion, it was designed so that a developer can easily find the code that is pertinent to what he/she needs. For example, to change the rate, look for the Rate routine. To set or change the voice, look for the Voice routine. And so on.

Also, the "Easy Text To Speech" function by Learning one has a good break down of Text-To-Speech requirements (what the developer might want to do) and an example of how to do it. See the References section in the first post for the link.

Does someone know a way to alternate between more than one voice. Example: Use Mike´s voice in one line and Anna´s in other?

This can be be done manually by doing exactly you described: Set the voice to Mike, speak the first line. Set the voice to Anna, speak the 2nd line. An so on.

A better solution might be to speak using a SAPI XML file which is an XML file with tags that instruct the TTS engine what to do. An example has been included with this project. Run the first example (Example1GUI.ahk), click on the "Open file..." button, go to the "Example Files" folder, and then select the "TTSXmlDemo.xml" file. You can speak this file by clicking on the "Play" button.