Speaking current date & time with Python?

Posted on
Mon Oct 17, 2022 3:12 pm
Japple55 offline
Posts: 224
Joined: Sep 26, 2015
Location: NE Tennessee

Speaking current date & time with Python?

Non-coder here. I've been reviewing the python scripting docs and am not finding much related to speech, aside from one example in the NOAA plugin documentation about speaking a variable. Can someone point me to where I might learn how to make Indigo speak the current date and time?
TIA,
Jim

Posted on
Mon Oct 17, 2022 6:22 pm
DaveL17 offline
User avatar
Posts: 6751
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Speaking current date & time with Python?

If you are just interested in having the spoken message read on the server machine -- the code is pretty easy. The format is controlled by the specifiers (% values) and the list of options can be found here: https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes

Code: Select all
import datetime

now = indigo.server.getTime()
string = datetime.datetime.strftime(now, "%A, %B %d at %-I %M")
indigo.server.speak(string)

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Tue Oct 18, 2022 4:21 pm
Japple55 offline
Posts: 224
Joined: Sep 26, 2015
Location: NE Tennessee

Re: Speaking current date & time with Python?

Thanks, Dave. That really helps!

Jim

Posted on
Tue Oct 18, 2022 4:27 pm
DaveL17 offline
User avatar
Posts: 6751
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Speaking current date & time with Python?

No worries. Interestingly, printed to the log you get:

Code: Select all
Tuesday, October 18 at 5 25
But the spoken message I hear is:

Tuesday, the eighteenth of October at five twenty-five.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest