Reputation: 554
I'm trying to create a espeak based talking clock completely in python
I want to know how to run
spk.speak('It is now <time>')
Each time the system hits time's like 12:00 1:00 etc
Upvotes: 1
Views: 2997
Reputation: 174624
You didn't specify what operating system you are using but running things at an interval is the job of some cron
-like process on Linux and Unix. On Windows, there is windows task scheduler.
You set these systems up to run your comand at intervals.
For example, this cron entry runs the script every hour:
0 * * * * /usr/bin/python /home/myuser/somefile.py
You an also use:
@hourly /usr/bin/python /home/myuser/somefile.py
@hourly
is an alias for 0 * * * *
Upvotes: 6
Reputation: 304137
import time
while True:
# sleep for the remaining seconds until the next hour
time.sleep(3600-time.time()%3600)
spk.speak('It is now <time>')
Upvotes: 11