This script repeatedly speaks a phrase until the requested maximum number of times or until the control device is turned off. The control device is a virtual device you can name anything you like. I use the device in HStouch screens so I can cancel the speech at any time by turning off the device. Useful for "nag announcements" that you want to keep going until someone responds. The device is automatically turned on and off by the script, so can be ignored unless you want to cancel the repeat early.
You pass it four parameters:
Parm 1 - what you want spoken
Parm 2 - how many times to repeat it
Parm 3 - how long to pause between repetitions (in seconds)
Parm 4 - the device reference id of the control device
Parm 5 - the speech client where it is to be spoken
(if you want it on all clients, pass an asterisk as the client name)
There is no error-trapping, so it will error-out if you pass the parms incorrectly. See below for an example of how to call it from an event.
I created this for my use and just thought I'd share.
Here's an example of calling it from an event.
You pass it four parameters:
Parm 1 - what you want spoken
Parm 2 - how many times to repeat it
Parm 3 - how long to pause between repetitions (in seconds)
Parm 4 - the device reference id of the control device
Parm 5 - the speech client where it is to be spoken
(if you want it on all clients, pass an asterisk as the client name)
There is no error-trapping, so it will error-out if you pass the parms incorrectly. See below for an example of how to call it from an event.
I created this for my use and just thought I'd share.
Code:
' RepeatSpeak.vb ' Parm 1 - what you want spoken ' Parm 2 - how many times to repeat it ' Parm 3 - how long to pause between repetitions ' Parm 4 - the device reference id of the control device ' Parm 5 - the speech client where it is to be spoken ' (if you want it on all clients, pass an asterisk as the client) Sub Main(ByVal parm as object) Dim Client as string Dim counter_value as integer = 0 Dim Delay as integer Dim Device as integer Dim HScomputerName = Environment.MachineName Dim parms() As String Dim pClient as string Dim Phrase as string Dim Repeats as integer parms = Split(parm.ToString,",") Phrase = parms(0) Repeats = parms(1) Delay = parms(2) Delay = Delay * 1000 'multiply passes seconds by 1000 to get milliseconds Device = parms(3) pClient = parms(4) 'If passed speech client is null or blank, use * If pClient = "" OR pClient = " " Then pClient = "*" End if Client = HScomputerName + ":" + pClient hs.WriteLog("Test Script", "phrase: " & phrase) hs.WriteLog("Test Script", "repeats: " & repeats) hs.WriteLog("Test Script", "delay: " & delay) hs.WriteLog("Test Script", "device: " & device) hs.WriteLog("Test Script", "client: " & client) ' Set on the control device hs.SetDeviceValueByRef(Device, 1, True) ' If the control device is on, continue If hs.DeviceValue(Device) > 0 ' Loop as long as the control device is on and the counter is less than 25 Do While hs.DeviceValue(Device) > 0 and counter_value < Repeats hs.Speak(Phrase, True, Client) counter_value = counter_value + 1 ' pause milliseconds System.Threading.Thread.Sleep(Delay) Loop End if ' Set off the control device hs.SetDeviceValueByRef(Device, 0, True) End Sub
Comment