Wilson WindowWare Tech Support

WinBatch WinBatch+Compiler WebBatch
Home | Tech Database | Tech BBS | White Papers | Purchase


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 Micrsoft Agent, L&H TrueVoice, and the Merlin character
; Available from http://msdn.microsoft.com/workshop/imedia/agent/agentdl.asp
;********************************************************************************

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

MyAgent.Connected = @TRUE

Characters = MyAgent.Characters

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


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

; Display the character      
;Genie.Show
;Genie.Hide
;Genie.MoveTo(700,300)
Merlin.Show
Merlin.MoveTo(900,620,10000)
Genie.Show
Genie.GestureAt(140,686)
GenieProcess = Genie.Play('Processing')
Merlin.Play('Confused')
Merlin.Speak('Ummm.... Genie, what are you doing?')
Merlin.Interrupt(GenieProcess)
Genie.Speak('Sorry, Merl...  Just trying to get a bit of work done here')
x = Merlin.Listen (@True)
Merlin.Play('Listening')
Peedy.Show
;Peedy.MoveTo(300,620)
;Robby.Show
;Robby.MoveTo(300,0)
Merlin.Speak("Hello all.")
Genie.Speak("Hello all.")
Robby.Speak("Hello all.")
Peedy.Speak("Hello all.")
Merlin.Speak("I am Merlin.")
Robby.Speak("I am Merlin.")
Peedy.Speak("I am Merlin.")
Genie.Speak("I am Merlin.")
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 
      TimeDelay(1)
      Merlin.Hide
      Genie.Hide
      Robby.Hide
      Peedy.Hide
      TimeDelay(3)
      Exit
   EndIf
   TimeDelay(1)
EndWhile