GEOSoft Posted February 20, 2008 Share Posted February 20, 2008 this code... it's ok for you? #include<Date.au3> $objsp = ObjCreate("SAPI.SpVoice") $hour = @HOUR - 0 $min = @MIN - 0 $strampm = "AM" If $hour >= 12 Then $strampm = "PM" If $hour > 12 Then $hour -= 12 If $hour = 0 Then $hour += 12 If $min < 10 Then $min = "o " & $min $strspeech = "It's, " & _DateDayOfWeek(@WDAY, 0) & ", " & _DateToMonth(@MON, 0) & ", " & @MDAY & ", " & @YEAR & ", at " & $hour & " " & $min & " " & $strampm ConsoleWrite($strspeech & @CRLF) $objsp.Speak($strspeech)That's fine but she wants it in 24 hour format nor 12 hour so the $hour calculation and the $strampm are not required. Also You have #included a lot of functions for the sake of a couple of arrays. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Diana (Cda) Posted March 17, 2008 Author Share Posted March 17, 2008 Okay, sorry for delay, but I've been off trying to figure out a few things and only now came back to tackle this again. It just seemed too much to handle initially. I finally successfully did all those seemingly complicated substitutions <g>. I'm guessing I did them okay as the script works. (I'm only now getting successful results working with variables, too.) I had to make some modifications, in the only way I knew how, since the date was getting said in a run-on sentence style that wasn't very understandable. I'm sure there's a much better and elegant way, but I have vast experience with TTS issues and it's not always feasible to rely on it to take care of things. Punctuation to control pauses often works but it varies from voice to voice. And some voices don't recognize punctuation at all, or they do weird things with it. I have several voices, so for me, it was more prudent to use "sleep" to control the pause lengths. Here's how the code stands now (word wrap needs watching):expandcollapse popup;----- Limits time this script will run to between the start and end times listed below: ----- #include <Date.au3> $StartTime = "04:00" ; adjust START time here in 24-hour time $EndTime = "11:01" ; adjust END time here in 24-hour time $CurrentTime = _NowTime(4) If Not ($CurrentTime >= $StartTime AND $CurrentTime <= $EndTime) Then ;It's not a valid time for script to run so exit without running Exit EndIf ; ========== My script down below: =========================================================== $objSp = ObjCreate("SAPI.SpVoice") $arrMonth = StringSplit("January|February|March|April|May|June|July|August|September|October|November|December", "|") $arrDay = StringSplit("Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday", "|") $arrHour = StringSplit("1|2|3|4|5|6|7|8|9|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty|twenty one|twenty two|twenty three", "|") $intHour = @HOUR $intMin = @MIN $strHour = "" $strMin = "" $strAMPM = "" $intMin = @MIN If $intMin > 9 Then $strMin = $intMin Else $strMin = "o " & $intMin; An O, not a zero (i.e. "twelve oh eight pm") EndIf If @HOUR = 0 Then $sHour = "zero" Else $sHour = $arrHour[@Hour] EndIf $strSpeech1 = "It's " & $arrDay[@WDAY] $strSpeech2 = $arrMonth[@MON] & ", " & @MDAY & ", " & @YEAR $strSpeech3 = $sHour & "hours, and" & " " & $strMin & "minutes" $objSp.Speak($strSpeech1) Sleep(350) $objSp.Speak($strSpeech2) Sleep(350) $objSp.Speak($strSpeech3) As I believe I mentioned initially, I need this only for the a.m., hence the time limit portion at the top of this script. If you're testing this outside the hours of 4:00 - 11:01 a.m., it won't work unless you change these start and end times. Also, the "hours" as is pretty typical, doesn't get pronounced correctly with WinXP's generic voice. I have that give me trouble in both NeoSpeech Paul and AT&T's Audrey, so that will need refining to get pronounced correctly (I'll try changing "hours" to what I use at home to get hours to be said correctly, something like spelling it "owe ers" does the trick). I have a talking clock that unfortunately is very limited. This great little freeware's smallest increments of a quarter hour and it doesn't tell you the date. So that's the reason for this script is to replace that freeware and instead to launch this via a reminder/launcher program that will be set to run every x number of minutes. AI will control the times during which a result is actually produced. Thanks. I believe this one is done. <g>. Cheers. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now