I used to use a nice little Random Speak script in HS2 from A.J. Griglak.
Anyone converted it to HS3 (or want to) or know of a better way to do it?
Here is what it did. You could setup a text file like rn_hello.txt that might look something like:
Then call call it from a txt script with
hs.RunEx "rn_random_speak.txt", "main","rn_hello.txt"
and it would speak one of the lines at random from the file.
Here is the HS2 "rn_random_speak.txt" code:
Anyone converted it to HS3 (or want to) or know of a better way to do it?
Here is what it did. You could setup a text file like rn_hello.txt that might look something like:
Code:
Hi Good Day Missed you Hello Hi sweetie Nice to see you Missed me? Hey
hs.RunEx "rn_random_speak.txt", "main","rn_hello.txt"
Here is the HS2 "rn_random_speak.txt" code:
Code:
' Based up on Speak Random Quote 1.1 by Christopher Lienau ' revised by A.J. Griglak ' ' PURPOSE: Speak a randomly selected greeting from pre-defined text file. ' INPUT: rn_bye.txt in HS Scripts directory ' OUTPUT: Speaks one of the lines that are randomly selected in the text file. ' ' Option Explicit DIM random, QuoteFileName, QuoteFile, FS, ThisQuoteFile, QuoteLine, Tcount, counter, quotes, aVoice Sub Main(QuoteFileName) aVoice= "" QuoteFile = hs.GetAppPath & "/scripts/" & QuoteFileName Set fs = CreateObject("Scripting.FileSystemObject") ' Read the number of different quotes (full lines ---> return) in the QuoteFIleName Set ThisQuoteFile = fs.OpenTextFile(QuoteFile, 1, False) counter = 0 Do While Not ThisQuoteFile.AtEndOfStream Tcount = Tcount + 1 QuoteLine = ThisQuoteFile.readline loop Set ThisQuoteFile = Nothing ' Generate a Random number from 1 to quotes (number of quotes in the file) quotes = Tcount random = Int(Rnd*quotes) ' Randomly select a quote from the file. Randomize random = INT((quotes - 1 + 1) * Rnd + 1) Set ThisQuoteFile = FS.OpenTextFile(QuoteFile, 1, False) counter = 0 Do While Not ThisQuoteFile.AtEndOfStream counter = counter + 1 QuoteLine = ThisQuoteFile.ReadLine If counter = random Then ' Debug to log ' hs.writelog "Number of Lines = ", Tcount If aVoice = "" then ' system.Speak Quoteline, true hs.Speak Quoteline, true else hs.Speak "<Voice Required='Name="+aVoice+"'>" & QuoteLine & "</Voice>",true End if End If Loop ThisQuoteFile.Close Set ThisQuoteFile = Nothing Set FS = Nothing end sub
Comment