Close

It talks

A project log for GPS Nixie Alarm Clock

GPS controlled nixie alarm clock with IR-receiver

tobias-rathjeTobias Rathje 02/11/2016 at 21:310 Comments

I thought it could be fun to make the clock able to speak the current time by using the say-command available from the command line in OS X:

NAME
       say - Convert text to audible speech

SYNOPSIS
           say [-v voice] [-r rate] [-o outfile [audio format options] | -n name:port | -a device] [-f file | string ...]

DESCRIPTION
       This tool uses the Speech Synthesis manager to convert input text to
       audible speech and either play it through the sound output device
       chosen in System Preferences or save it to an AIFF fil

I made a shell script to produce audio files with spoken numbers from 0 to 59 and converted them to AD4.

Using this small routine, the clock speaks the current time when the play/pause-button on the Apple remote is pressed:

/*
 * Speak current HH and MM using voice files from 0 to 59 starting at position 400
 */
void say_clock()
{
	// hours
	wtv020_cmd(400 + lcl_time->tm_hour);
	_delay_ms(1000);

	// extend delay for long hour numbers
	if (lcl_time->tm_hour > 20)
		_delay_ms(500);

	// leading zero when single digit minutes
	if (lcl_time->tm_min < 10)
	{
		wtv020_cmd(400);
		_delay_ms(600);
	}

	// minutes
	wtv020_cmd(400 + lcl_time->tm_min);
	_delay_ms(1500);

	// silence
	wtv020_cmd(0xffff);
}

Discussions