WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Speech

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

MS Agent (Merlin) - Sample Code to Convert Text to Speech

Keywords:   Text to Speech merlin  ms agent

Question:

I was wondering if anyone had figured out how to use the different voices that ship with the Microsoft SDK.

Answer:

I recall fighting with that for a while long ago, and did not manage to get anything other than the default voice.

There was a discussion some time ago about using the MS Agent (Merlin and friends) to convert text to speech.

Here's my sample code based on what had been posted.

You may also want to check:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msagent/agentstartpage_7gdh.asp?frame=true 
to get further info.
;********************************************************************************
; Microsoft Agent Example
;
; Requires:
; Microsoft Agent
; Merlin character
; (optional) Lernout & Hauspie TruVoice TTS engine - American english
; 
; Downloaded from:
; Microsoft Agent: http://activex.microsoft.com/activex/controls/agent2/msagent.exe
; Various Character files: http://www.microsoft.com/msagent/downloads/user.asp#character
; For this example download the Merlin character.
; Text To Speach engine files: http://www.microsoft.com/msagent/downloads/user.asp#tts
;
; Notes: Install the SAPI 4.0 runtime support below if you are using the Windows XP operating 
;        system and intend to use any of the speech components here with Microsoft Agent.
;
;        Also, install this SAPI 4.0 runtime support if you intend to use the L&H TTS3000 
;        engines with the Microsoft Agent Genie, Merlin, Peedy and Robby characters. These 
;        characters are compiled to use the L&H TruVoice engine as the default speech output engine 
;        and the SAPI 4.0a runtime is necessary to set these characters' TTSModeID property to use 
;        the TTS3000 engines. Other Microsoft Agent characters may also require this SAPI 4.0 runtime 
;        support to set their TTSModeID property. 
;        http://www.microsoft.com/msagent/downloads/user.asp#sapi
;
;
;
;
;********************************************************************************

; Create an instance of the control 
MyAgent = ObjectOpen("Agent.Control.2")

MyAgent.Connected = @TRUE

Characters = MyAgent.Characters

; Load the character
Characters.Load("Merlin", "Merlin.acs")
;Characters.Load("Genie", "Genie.acs")
;Characters.Load("Peedy", "peedy.acs")
;Characters.Load("Goober", "Robby.acs")

Merlin = Characters.Character("Merlin")
;Genie = Characters.Character("Genie")
;Peedy = Characters.Character("Peedy")
;Robby = Characters.Character("Goober")

; Display the character      
Merlin.Show
Merlin.MoveTo(900,620,10000)
Merlin.Play('Confused')
Merlin.Speak("Hello all.")
Merlin.MoveTo(340,240)
;Note the use of single quotes so you can use double quotes in the map command
;The map command has 2 parameters.  The first is how you want the text pronounced.
;The second is how you want it shown in the balloon
Merlin.Speak('Using agent within \Map="Win Batch"="WinBatch"\ is not that difficult.')
Merlin.Speak('Since you are running an \Map="Oh Lay"="OLE"\ object,')
Merlin.Speak('In order to sync \Map="Win Batch"="WinBatch"\ commands with things happening in agent,')
Merlin.Speak("You loop until the 'status' of a command is complete.")
Merlin.think('Any idiot ought to know that!')
Merlin.MoveTo(620,460)
GestureRight = Merlin.Play("GestureRight")
While @TRUE
   If GestureRight.Status == 0 then break ;if gesture command has succesfully completed
EndWhile
Merlin.Think('Man, this machine is slooooow...')
Run("notepad","")
TimeDelay(3)
SendKey("This is a notepad example.{ENTER}")
Merlin.Play("RestPose")
Merlin.Speak("Now I'll close notepad, choosing not to save the file")
TimeDelay(5)
SendKey("!fx")
TimeDelay(1)
SendKey("n")
AgentDone = Merlin.Speak("Thus ends this agent example.")
While @true
   If AgentDone.Status == 0 
      Merlin.Hide
      Exit
   EndIf
   TimeDelay(0.5)
EndWhile


Article ID:   W15709
File Created: 2003:09:04:15:21:34
Last Updated: 2003:09:04:15:21:34