On the mac there is a feature which allows you to get your computer to verbally announce the time on the hour, is there something similar on Ubuntu? That is is there a package which already does this or do I need to configure something like say to read out the time on the hour? And if so then how do I do that? I am running Ubuntu GNOME 15.04 with GNOME 3.16.
Asked
Active
Viewed 2,243 times
11
-
`date` outputs it in text. maybe you could pipe that through a text-to-speech program? – Promille Oct 18 '15 at 10:47
-
@Wildcard: Though I would have to greatly trim and change the output of that command because it says too much, all I need and want on the hour is something like (`[time]` replaced with the hour): `It is now [time] O'clock` – Oct 18 '15 at 10:59
-
See my answer, hope that can help some. You could also add something like "It is now..." before it announces the time with `sed` – Promille Oct 18 '15 at 11:00
-
Wow, this sounds annoying. – Lightness Races in Orbit Oct 18 '15 at 14:34
-
@LightnessRacesinOrbit: Yes, it is becoming so... :D – Oct 18 '15 at 14:48
2 Answers
22
You could use your crontab
Create a little script
mkdir -p ~/bin nano ~/bin/say_houradd the code below
#!/usr/bin/env bash my_date=$(date +'%H:%M:%S') padsp espeak "$my_date"and set executable rights
chmod +x ~/bin/say_hourEdit your crontab via
crontab -eand add the configuration below
0 * * * * bin/say_hour
You can replace the espeak line with one of the possibilities below
sudo apt-get install espeak
espeak $(date +"%H:%M:%S")
espeak $(date +%T)
# Adjust speed with `-s`, in words per minute, default is 160
espeak -s 10 $(date +"%H:%M:%S")
or
sudo apt-get install festival
date +"%H:%M:%S" | festival --tts
date +%T | festival --tts
or
sudo apt-get install speech-dispatcher
spd-say $(date +"%H:%M:%S")
spd-say $(date +%T)
# Adjust speed with (-100 .. 0 .. 100)
spd-say -r -50 $(date +%T)
%I– hour (01..12) format%H– hour in (00..23) format%M– minute (00..59)%S– second (00..60)%T–HH:MM:SSin 24 Format
More options via man date, man espeak, man festival and man spd-say
A.B.
- 89,123
- 21
- 245
- 323
-
-
-
1
-
Could you also please include in your answer how to get it to run on the hour, perhaps with a cron job as I know about them and how they work, but have never actually set one up manually. – Oct 18 '15 at 11:22
-
In fact, I have a Raspberry Pi under my desk which does exactly this (and much more). It runs not the full Festival but Festival Light (`flite`). It speaks the time at the full hour, and (hh:mm) whenever I send it a Wake-on-Lan packet. I set it to speak slightly slower (`set Duration_stretch=1.3`) to get a more pleasant tone of voice. – Jos Oct 18 '15 at 14:23
-
A 2022 update/supplement to @A.B. 's answer: spd-say seems to be the preferred/default TTS tool. However, it requires XDG_RUNTIME_DIR to be set, yet cron does not do this for you. See this nice solution: https://emacs.stackexchange.com/a/61778 . With that at the top of your shell script, spd-say should successfully run when invoked by crond. Side note: I found no mention of XDG_RUNTIME_DIR in the manpages for spd-say and speech-dispatcher, nor in the output of the "silent" spd-say call. – Justin Sep 14 '22 at 17:05
5
This gives you the time in speech (thanks to kos for providing better syntax) :
First install say , which is found in gnustep-gui-runtime:
sudo apt-get install gnustep-gui-runtime
Then run it.
24-hour mode:
say "$(date +%R)"
12-hour mode
say "$(date +%I:%M%p)"
Promille
- 508
- 3
- 12
-
Could you also please include in your answer how to get it to run on the hour, perhaps with a cron job as I know about them and how they work, but have never actually set one up manually. – Oct 18 '15 at 11:13
-
Sorry, I don't know how to do that @ParanoidPanda . If someone else does, they can post it as a comment and I'll include it in my post – Promille Oct 18 '15 at 11:21
-
@ParanoidPanda http://askubuntu.com/questions/2368/how-do-i-set-up-a-cron-job ;) – kos Oct 18 '15 at 11:23
-
@Wildcard: A.B. has included it in his answer so you could probably just take it from there or read what kos commented. :) – Oct 18 '15 at 11:34
-
@ParanoidPanda A.B. has the accepted answer, so it's not really that important – Promille Oct 18 '15 at 11:38
-