While writing a letter in MS Word, I accidentally clicked on the help button and this animated little thing on a a bike jumped up and presented me with an input box. I’ve seen it a few times before, but this time I wondered if I could write a program that could animate characters in Delphi.
Delphi and Microsoft Agent - Modifying speech out (Page 3 of 4 )
In the previous section we used the Speak() procedure to make Merlin read the text in the memo. We can use that method to modify speech by using tags. These tags can be used to change the output expression of the character. Speech tags follow a very specific format:
All tags begin and end with a backslash character ().
Tags are white space dependent i.e Merlin is not the same as Merlin .
The single backslash character is not enabled within a tag. To include a backslash character in a text parameter of a tag, use a double backslash.
Tags are case insensitive, i.e Merlin is the same as MERLIN.
From the Microsoft documentation there are eleven main tags that can be used to alter speech output. Below are some of them as laid out in the Microsoft Documentation:
Chr
Description: Sets the character of the voice.
Syntax: Chr=string
String: A string specifying the character of the voice.
Part
Description
"Normal" (default)
A normal tone of voice
"Monotone"
A monotone voice
"Whisper"
A whispered voice
Ctx Tag
Description: Sets the context of the output text.
Syntax: Ctx=string
String: A string specifying the context of the text that follows, which determines how symbols or abbreviations are spoken.
Part
Description
"Address"
Addresses and/or phone numbers.
"E-mail"
Electronic mail.
"Unknown" (default)
Context is unknown.
Lst Tag
Description: Repeats last spoken statement for the character.
Syntax: Lst
Remarks: This tag enables a character to repeat its last spoken statement. This tag must appear by itself in the Speak method; no other text or parameters can be included. When the spoken text is repeated, any other tags included in the original text are repeated, except for bookmarks. Any .WAV and .LWV files included in the text are also repeated.
Map Tag
Description: Maps spoken text to text displayed in the word balloon.
Syntax: Map="spokentext"="balloontext"
Remarks: This tag enables you to use different spoken text than that displayed in the word balloon.
Part
Description
spokentext
A string specifying the text for spoken output.
balloontext
A string specifying the text for word balloon output.
Mrk Tag
Description: Defines a bookmark in the spoken text.
Syntax: Mrk=number
Remarks: When the server processes a bookmark, it generates a bookmark event. You must specify a number greater than zero (0) and not equal to 2147483647 or 2147483646.
Part
Description
number
A Long integer value that identifies the bookmark.
Pau Tag
Description: Pauses speech for the specified number of milliseconds.
Syntax: Pau=number
Part
Description
number
The number of milliseconds to pause.
Pit Tag
Description: Sets the baseline pitch of the output to the specified value in hertz.
Syntax: Pit=number
Remarks: This tag is supported only for TTS-generated output. The range of values for the parameter may vary depending on the installed TTS engine.
Part
Description
number
The pitch in hertz.
There are a couple more that you can use to make your agent speak in a way that you like. To make Merlin whisper the text that he reads off the memo, change the code in the button1 procedure from this:
procedure TForm1.Button1Click(Sender: TObject); begin Merlin.show(false); Merlin.speak(memo1.text, ''); end;
To this:
procedure TForm1.Button1Click(Sender: TObject); begin Merlin.show(false); Merlin.speak(Chr="Whisper"memo1.text, ''); end;