Sub Main(ByVal Parms As Object)
Dim preset As String = "1"
Dim textToSpeak As String = "Please Provide Your Text To Speak"
Dim device As String = "Alexa:All"
Dim finalString As String = ""
Dim debugMode As Boolean = True
Dim args() As String = Parms.ToString().Split(","c)
hs.WriteLog("Script Debug (v2024-10-22.002)", "Received Parameters: " & String.Join(",", args))
If args.Length > 0 AndAlso Not String.IsNullOrEmpty(args(0).Trim()) Then
If debugMode Then hs.WriteLog("Script Debug (v2024-10-22.002)", "Preset: " & preset)
If args.Length > 1 AndAlso Not String.IsNullOrEmpty(args(1).Trim()) Then
textToSpeak = args(1).Trim()
If debugMode Then hs.WriteLog("Script Debug (v2024-10-22.002)", "Text to Speak: " & textToSpeak)
If args.Length > 2 AndAlso Not String.IsNullOrEmpty(args(2).Trim()) Then
device = "Alexa:" & args(2).Trim()
If debugMode Then hs.WriteLog("Script Debug (v2024-10-22.002)", "Device: " & device)
hs.SetDeviceString(3433, textToSpeak, True)
finalString = "<" & preset & "> " & textToSpeak
If debugMode Then hs.WriteLog("Script Debug (v2024-10-22.002)", "Final String: " & finalString)
If debugMode Then hs.WriteLog("Script Debug (v2024-10-22.002)", "Device: " & device)
hs.Speak(finalString, False, device)
hs.WriteLog("Script Error (v2024-10-22.002)", "Error: " & ex.Message)