Teaching QTP to Speak Using Karaoke

QTP/UFT Published on:
QTP Singing Robot

Using Microsoft Speech API with QTP

I just found a Microsoft API that allows you to create QTP scripts with voice feedback. The speech API gives you the ability to use speech recognition and speech synthesis within your QTP scripts.

What you need to get started to get QTP to Speak

Not sure how many actual business scripting uses you would actually need this for, but it’s cool to know it can be done. Here’s what you need to get started:

First, create an instance of the SAPI.SpVoice

Set voice = CreateObject(“SAPI.SpVoice”)

Next, use the Speak method to start the speaking of the text string.

Voice.Speak “Joe Colantonio Dot Com”

  • You can control other things like Volume (level of the voice) and Rate (how slow or fast you want the speaking rate to be). For the all the methods available take a look at:


Teaching QTP to “Sing”

Isn’t that cool!?! You can even read from a text file — which can create some interesting results, like having QTP read the text of this blog post, read the lyrics to your favorite song or quote lines from your favorite movie. Just be cautious if it asks, “Shall we play a game?” It wouldn’t be smart to answer, “How about Global Thermal Nuclear War?” (Those of you who’ve seen the movie War Games will get the reference…)

Code used to read from a text file for the video for this post:

Set voice = CreateObject(“SAPI.SpVoice”)

Set oFso = CreateObject(“Scripting.FileSystemObject”)

intReadWriteAppend = 1

Set strFileName = oFso.OpenTextFile(“C:\blogpost.txt”, 1, false)

      DO while strFileName.AtEndOfStream = false

             strFileLine = strFileName.Readline

             fVoice.Speak strFileLine



3 responses to “Teaching QTP to Speak Using Karaoke”

  1. Hi,

    Is there anyway to increase the volume of the text to speech as I am trying to use this to leaver a voicemail message in Skype and need to ensure this can be heard clearly

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

QTP Singing Robot