13

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.

5
  • date outputs it in text. maybe you could pipe that through a text-to-speech program?
    – Promille
    Commented Oct 18, 2015 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
    – user364819
    Commented Oct 18, 2015 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
    Commented Oct 18, 2015 at 11:00
  • Wow, this sounds annoying. Commented Oct 18, 2015 at 14:34
  • @LightnessRacesinOrbit: Yes, it is becoming so... :D
    – user364819
    Commented Oct 18, 2015 at 14:48

2 Answers 2

24

You could use your crontab

  1. Create a little script

     mkdir -p ~/bin
     nano ~/bin/say_hour
    

add 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_hour
    
  1. Edit your crontab via

     crontab -e
    

and 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)
  • %P – period (AM/PM)
  • %THH:MM:SS in 24 Format

More options via man date, man espeak, man festival and man spd-say

6
  • That doesn't work, it just wants input and gives me one of these > .
    – user364819
    Commented Oct 18, 2015 at 11:12
  • @A.B nice=)...Is it possible to adjust speed ?
    – Ravan
    Commented Oct 18, 2015 at 11:12
  • 1
    wow @A.B working :) +1
    – Ravan
    Commented Oct 18, 2015 at 11:16
  • 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.
    – user364819
    Commented Oct 18, 2015 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
    Commented Oct 18, 2015 at 14:23
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)"
6
  • 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.
    – user364819
    Commented Oct 18, 2015 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
    Commented Oct 18, 2015 at 11:21
  • @ParanoidPanda askubuntu.com/questions/2368/how-do-i-set-up-a-cron-job ;)
    – kos
    Commented Oct 18, 2015 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. :)
    – user364819
    Commented Oct 18, 2015 at 11:34
  • @ParanoidPanda A.B. has the accepted answer, so it's not really that important
    – Promille
    Commented Oct 18, 2015 at 11:38

You must log in to answer this question.