A Bash Program to Generate Voice Output of Local Time on Raspberry Pi

Introduction: A Bash Program to Generate Voice Output of Local Time on Raspberry Pi

About: Student living in Mumbai. Love to innovate.

Hey netizens! This is the first Instructable I've made! This site has helped me immensely as a student, learning to DIY. I want to help this site in return.

Now, for the details, this is a simple talking clock that says the day, date, month, time and year in English using the picoTTS. A TTS is a text to speech converter and is a nifty little tool that can go well with a wide range of projects. There are more TTS softwares like eSpeak and Festival but I found pico to be the best.

More details here:


YouTube video here :::

Step 1: Things Needed

A Raspberry Pi with Raspbian installed and all its peripherals(Mouse, Keyboard, HDMI/VGA)

An Audio Output

A working internet connection to the Raspberry Pi.

Step 2: Let's Get Started!

I've referred to this site while installing

I've tried to break it down

1 - Go to the Command Line and type - nano /etc/apt/sources.list

2 - Check if it contains (uncommented) the following lines:

deb http://mirrordirector.raspbian.org/raspbian/ wheezy main contrib non-free rpi

deb-src http://mirrordirector.raspbian.org/raspbian/ wheezy main contrib non-free rpi

To uncomment, delete the # that may be in the beginning of any line.

Depending on your version of Raspbian, the wheezy will be replaced by your respective version name. For me it was jessie.

Step 3: Lets Get Installing!

Type these commands in command line

sudo apt-get update

sudo apt-get install fakeroot debhelper automake autoconf libtool help2man libpopt-dev hardening-wrapper

mkdir pico_build

cd pico_build

apt-get source libttspico-utils

After downloading the sources, you should find a folder named like svox-1.0+git20110131 that will contain all the files. Note that the last part could be different, so please check before proceeding.Enter the sources folder and prepare the packages:

cd svox-1.0+git20110131

dpkg-buildpackage -rfakeroot -us -uc

Step 4: Final Steps

Now, in case you are on jessie, the last command will stop pretty quickly.

In that case, download these files


Install as so-

sudo dpkg -i filename.deb

For example sudo dpkg -i libttspico-utils_1.0+git20130326-3_armhf.deb

Install the packages in order of downloading, ie. /libttspico-data, libttspico0, libttspico-utils

If you are on wheezy, the above step isnt necessary. Install in the same way!

Step 5: Getting It to Work

Try this

pico2wave -w test.wav "it works! "

aplay test.wav

If this code works, your project is 90% over.

Step 6: Making a Clock

If you type date, into the command line it will give you the date. I used this function to create an executable shell script.

Type nano talking_clock.sh, paste the following code and press Ctrl+o, Ctrl+x.



while : do

pico2wave -w test.wav "Today is $(date +%A) $(date +%d) $(date +%B) $(date +%Y). The time is $(date +%l) $(date +%M) $(date +%p) $(date +%Z)"

aplay test.wav

sleep 60


Type -

chmod +x talking_clock.sh

To execute -



#!/bin/bash - specifies the language we are using, in this case its bash

while : do - an infinite loop

pico2wave -w test.wav "Today is $(date +%A) $(date +%d) $(date +%B) $(date +%Y). The time is $(date +%l) $(date +%M) $(date +%p) $(date +%Z)" - creates a .wav file named test, that stores the converted string in the following format... "Today is Thursday 01 January 2016. The time is 01 59 PM IST"

To learn about some more functions, type date --help in the terminal window.

Step 7: Thank You!

You could make it more elaborate, add conditional statements and make it respond to statements to make a basic humanoid robot for instance. The possibilities are endless!

You could check my instagram (@arpimatic_lab), where I've uploaded a video of this at work!

I'll try to elaborate on the concepts at work soon.

Thank you all so very much!

I'm open to constructive criticism.

If you liked this 'ible please like and subscribe.

Raspberry Pi Contest 2016

Participated in the
Raspberry Pi Contest 2016

Be the First to Share


    • Make It Bridge

      Make It Bridge
    • Game Design: Student Design Challenge

      Game Design: Student Design Challenge
    • For the Home Contest

      For the Home Contest



    6 years ago

    Thank You all for the 300 views!