Sign in to follow this  
Followers 0
Diana (Cda)

[Resolved] Way to speak full days, months, time rather than numbers?

22 posts in this topic

#1 ·  Posted (edited)

#include <Date.au3>

$oSp = ObjCreate("SAPI.SpVoice")
$oSp.Speak("It's")
Sleep(50)
$oSp.Speak(@MON & @MDAY & @YEAR)
Sleep(50)
$oSp.Speak(@HOUR & @MIN & "a.m.")
I tried all sorts of combinations for the date and time syntax for this script that will run in a.m., but I just get a number-style of readout and nothing like this:

"It's Tuesday, February 19, 2008, nine-thirty a.m.".

I've looked through the "Macros" entry in the help file but I couldn't find any macro syntax that would give the long form of readout that's needed instead of the number one. Is there anything that will do what's needed rather than the above number style?

Thanks! :)

Edited by Diana (Cda)

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

#include <Date.au3>

$oSp = ObjCreate("SAPI.SpVoice")
$oSp.Speak("It's")
Sleep(50)
$oSp.Speak(@MON & @MDAY & @YEAR)
Sleep(50)
$oSp.Speak(@HOUR & @MIN & "a.m.")
I tried all sorts of combinations for the date and time syntax for this script that will run in a.m., but I just get a number-style of readout and nothing like this:

"It's Tuesday, February 19, 2008, nine-thirty a.m.".

I've looked through the "Macros" entry in the help file but I couldn't find any macro syntax that would give the long form of readout that's needed instead of the number one. Is there anything that will do what's needed rather than the above number style?

Thanks! :)

hah I am having fun with this now

$oSp = ObjCreate("SAPI.SpVoice")
$oSp.Speak("Today's date is " & @MON &  " " & @MDAY & " " & @YEAR)

if @Hour >=12 then 
    $oSp.Speak("The time is " & @HOUR & " " & @MIN & "P M")
Else
    $oSp.Speak("The time is " & @HOUR & " " & @MIN & "a m")
EndIf

Converted for 12 hour clock

$oSp = ObjCreate("SAPI.SpVoice")
$oSp.Speak("Today's date is " & @MON &  " " & @MDAY & " " & @YEAR)

if @Hour >= 12 then 
    if @Hour >= 13 Then
            $oSp.Speak("The time is " & @HOUR-12 & " " & @MIN & "P M")
    Else
            $oSp.Speak("The time is " & @HOUR & " " & @MIN & "P M")
    EndIf
Else
    $oSp.Speak("The time is " & @HOUR & " " & @MIN & "A M")
EndIf
Edited by ReaImDown

[u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

sorry, I just read the title :)

if @mon = 1 then

$Mon = "January

elseif @Moh = 2 then

$Mon = "February"

..........ETC

Endif

then make it read $Month instead of @Mon

Edited by ReaImDown

[u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

sorry, I just read the title :)

if @mon = 1 then

$Mon = "January

elseif @Moh = 2 then

$Mon = "February"

..........ETC

Endif

then make it read $Month instead of @Mon

Better yet

$m_Array = StringSplit("January|February|March|April|May|June|July|August|September|October|November|December", "|")
$d_Array = StringSplit("Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday", "|")
$oSp = ObjCreate("SAPI.SpVoice")
$oSp.Speak("It's")
Sleep(50)
$oSp.Speak($m_Array(@MON) & $d_Array(@MDAY) & @YEAR)
Sleep(50)
$oSp.Speak(@HOUR & @MIN & "a.m.")

Edit: Watch for line wrap in $m_Array

Edited by GEOSoft

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!"

Share this post


Link to post
Share on other sites

GeoSoft - You don't even need that first array:

_DateToMonth(@MON, 0)

Share this post


Link to post
Share on other sites

GeoSoft - You don't even need that first array:

_DateToMonth(@MON, 0)

What I really don't need is to #include Date.au3. :)

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!"

Share this post


Link to post
Share on other sites

$m_Array = StringSplit("January|February|March|April|May|June|July|August|September|October|November|December", "|")
$d_Array = StringSplit("Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday", "|")
$oSp = ObjCreate("SAPI.SpVoice")
$oSp.Speak("It's")
Sleep(50)
$oSp.Speak($m_Array(@MON) & $d_Array(@MDAY) & @YEAR)
Sleep(50)
$oSp.Speak(@HOUR & @MIN & "a.m.")
Edit: Watch for line wrap in $m_Array
No problems with word-wrap. I get an error, though, right under the "$" right at the beginning, like so:
$oSp.Speak($m_Array(@MON) ...
$oSp.Speak(^ ERROR

Error:  Error in expression.

Share this post


Link to post
Share on other sites

GeoSoft - You don't even need that first array:

_DateToMonth(@MON, 0)

Since I get an error with regards to the first array, how would you incorporate this into the above code, pls?

Thanx. :0

Share this post


Link to post
Share on other sites

Change this line:

$oSp.Speak($m_Array(@MON) & $d_Array(@MDAY) & @YEAR)

to

$oSp.Speak($m_Array[@MON] & $d_Array[@MDAY] & @YEAR)

Share this post


Link to post
Share on other sites

No problems with word-wrap. I get an error, though, right under the "$" right at the beginning, like so:

$oSp.Speak($m_Array(@MON) ...
$oSp.Speak(^ ERROR

Error:  Error in expression.
Arrays use squared bracket like : $m_Array[@MON].

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Arrays use squared bracket like : $m_Array[@MON].

Jos

:) xxxxxxxxxxxxxxx :)

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!"

Share this post


Link to post
Share on other sites

You can skip the kisses ... I am not into male bonding :)

Won't be GEOSoft much longer! :)

Share this post


Link to post
Share on other sites

Won't be GEOSoft much longer! :)

Don't go there. Jos already did enough.

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!"

Share this post


Link to post
Share on other sites

$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", "|")
$intHour  = @HOUR
$intMin   = @MIN
$strHour  = ""
$strMin   = ""
$strAMPM  = ""

If $intHour > 12 Then
    $strAMPM = "PM"
    $strHour = $intHour - 12
Else
    $strAMPM = "AM"
    $strHour = $intHour
EndIf
If $intMin > 9 Then
    $strMin = $intMin
Else
    $strMin = "o " & $intMin; An O, not a zero (i.e. "twelve oh eight pm")
EndIf

$strSpeech = "It's, " & $arrDay[@WDAY] & ", " & $arrMonth[@MON] & ", " & @MDAY & ", " & @YEAR & ", at " & $strHour & " " & $strMin & " " & $strAMPM
$objSp.Speak($strSpeech)

Putting a comma in the speech will insert the delay you're trying to achieve.


My UDFs: ExitCodes

Share this post


Link to post
Share on other sites

$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", "|")
$intHour  = @HOUR
$intMin   = @MIN
$strHour  = ""
$strMin   = ""
$strAMPM  = ""

If $intHour > 12 Then
    $strAMPM = "PM"
    $strHour = $intHour - 12
Else
    $strAMPM = "AM"
    $strHour = $intHour
EndIf
If $intMin > 9 Then
    $strMin = $intMin
Else
    $strMin = "o " & $intMin; An O, not a zero (i.e. "twelve oh eight pm")
EndIf

$strSpeech = "It's, " & $arrDay[@WDAY] & ", " & $arrMonth[@MON] & ", " & @MDAY & ", " & @YEAR & ", at " & $strHour & " " & $strMin & " " & $strAMPM
$objSp.Speak($strSpeech)

Putting a comma in the speech will insert the delay you're trying to achieve.

I forgot how to set the pause in SAPI. I know there is a Pause command for Agent Character speech but I couldn't find the same thing for SAPI. Thanks

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!"

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

Change this line:

$oSp.Speak($m_Array(@MON) & $d_Array(@MDAY) & @YEAR)

to

$oSp.Speak($m_Array[@MON] & $d_Array[@MDAY] & @YEAR)

Changed to:
$m_Array = StringSplit("January|February|March|April|May|June|July|August|September|October|November|December", "|")
$d_Array = StringSplit("Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday", "|")
$oSp = ObjCreate("SAPI.SpVoice")
$oSp.Speak("It's")
Sleep(50)
$oSp.Speak($m_Array[@MON] & $d_Array[@MDAY] & @YEAR)
Sleep(50)
$oSp.Speak(@HOUR & @MIN & "a.m.")
This is neat; I'm learning all sorts of AI errors I never knew about <lol>. Now I get this one, whatever the heck it means!

-----------------------

$oSp.Speak($m_Array[@MON] & $d_Array[@MDAY] & @YEAR)

$oSp.Speak($m_Array[@MON] & ^ERROR

Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded.

-----------------------

Thanks. :)

Edited by Diana (Cda)

Share this post


Link to post
Share on other sites

$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", "|")
$intHour  = @HOUR
$intMin   = @MIN
$strHour  = ""
$strMin   = ""
$strAMPM  = ""

If $intHour > 12 Then
    $strAMPM = "PM"
    $strHour = $intHour - 12
Else
    $strAMPM = "AM"
    $strHour = $intHour
EndIf
If $intMin > 9 Then
    $strMin = $intMin
Else
    $strMin = "o " & $intMin; An O, not a zero (i.e. "twelve oh eight pm")
EndIf

$strSpeech = "It's, " & $arrDay[@WDAY] & ", " & $arrMonth[@MON] & ", " & @MDAY & ", " & @YEAR & ", at " & $strHour & " " & $strMin & " " & $strAMPM
$objSp.Speak($strSpeech)

Putting a comma in the speech will insert the delay you're trying to achieve.

Ah, neat. Sometimes that works and sometimes it doesn't in some apps. That's a neat replacement for the Sleep() code I had, for sure.

I stumbled upon using punctuation as a pause effect in my tts reminder/scheduler freeware called PUAC though the commas and other punctuation stopped working in XP as a means to pause between words (lots of stuff no longer works in XP <g>).

Anywho, this is great. I only needed an a.m. script but this is much better. I probably can just block out the p.m. script for the current need using ";", I'm guessing. Will try that for this current a.m. need.

There's only one little thing left re easily understanding spoken time. I need the 24-hour clock format so that must stay. Even my wrist watch is set to display in that format, esp. since all the posted bus schedules around town display in 24-hour mode so I got into the 24-hour habit nearly 20 years ago. The only difficulty with it is the leading zero. It's kind of weird having to stop for a half moment to translate "zero six forty-six a.m." to just plain "six forty-six a.m.". One last request although you've done so much already, is there a way to get it to not read those zeros?

I have an excellent talking time freeware, but it doesn't read off the date and the highest frequency it can be set to run is every 15 minutes. This script would be an incredible workaround where I get the best of both worlds. I'll put code in it to have it repeat every 5 minutes during critical period in morning (hey, I know how to do that now!! <g>).

Thanks. :)

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

Ah, neat. Sometimes that works and sometimes it doesn't in some apps. That's a neat replacement for the Sleep() code I had, for sure.

I stumbled upon using punctuation as a pause effect in my tts reminder/scheduler freeware called PUAC though the commas and other punctuation stopped working in XP as a means to pause between words (lots of stuff no longer works in XP <g>).

Anywho, this is great. I only needed an a.m. script but this is much better. I probably can just block out the p.m. script for the current need using ";", I'm guessing. Will try that for this current a.m. need.

There's only one little thing left re easily understanding spoken time. I need the 24-hour clock format so that must stay. Even my wrist watch is set to display in that format, esp. since all the posted bus schedules around town display in 24-hour mode so I got into the 24-hour habit nearly 20 years ago. The only difficulty with it is the leading zero. It's kind of weird having to stop for a half moment to translate "zero six forty-six a.m." to just plain "six forty-six a.m.". One last request although you've done so much already, is there a way to get it to not read those zeros?

I have an excellent talking time freeware, but it doesn't read off the date and the highest frequency it can be set to run is every 15 minutes. This script would be an incredible workaround where I get the best of both worlds. I'll put code in it to have it repeat every 5 minutes during critical period in morning (hey, I know how to do that now!! <g>).

Thanks. :)

Change this line

$strSpeech = "It's, " & $arrDay[@WDAY] & ", " & $arrMonth[@MON] & ", " & @MDAY & ", " & @YEAR & ", at " & $strHour & " " & $strMin & " " & $strAMPM
to

If @HOUR = 0 Then
   $sHour = "zero"
Else
   $sHour = $arrHour[@Hour]
EndIf
$strSpeech = "It's, " & $arrDay[@WDAY] & ", " & $arrMonth[@MON] & ", " & @MDAY & ", " & @YEAR & ", at " & $sHour & " " & $strMin

replace

$arrHour  = StringSplit("1|2|3|4|5|6|7|8|9|ten|eleven|twelve", "|")

with

$arrHour  = StringSplit("1|2|3|4|5|6|7|8|9|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|ninete
en|twenty|twenty one|twenty two|twenty three", "|")

and change the following

$intHour  = @HOUR
$intMin   = @MIN
$strHour  = ""
$strMin   = ""
$strAMPM  = ""

If $intHour > 12 Then
    $strAMPM = "PM"
    $strHour = $intHour - 12
Else
    $strAMPM = "AM"
    $strHour = $intHour
EndIf
If $intMin > 9 Then
    $strMin = $intMin
Else
    $strMin = "o " & $intMin; An O, not a zero (i.e. "twelve oh eight pm")
EndIf

to

$intMin   = @MIN

If $intMin > 9 Then
    $strMin = $intMin
Else
    $strMin = "o " & $intMin; An O, not a zero (i.e. "twelve oh eight pm")
EndIf

Edit: Again watch for line wrap

Edited by GEOSoft

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!"

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

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)
Edited by psandu.ro

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0