In my last post for the VS1053 breakout board, I left off with simply playing an MP3 by pressing a button. Basically a "Hello World" for the breakout board.
Now it's time to dig in and see what it'll take to make a talking clock.
I first started by making a list of all the words I'd need spoken: "It is", "one", "two", "three"..."o'clock", etc.
I then used OS X's text-to-speech function to read them back to me as I captured the audio with QuickTime.
I then dragged the file into GarageBand for editing.
I cut each word into individual sound bites and exported them as separate MP3s.
With this bank of sound bites, I'd be able to annunciate any time by concatenating the MP3 files.
For example, for "It is 9:45", I'd just have to play back 4 individual sound bites:
Here it is in action...
Hummmm. You hear that? That's a problem. Looked good on paper. Seemed OK in my head. In the real world? Less than ideal. There is way too much of a delay between tracks. It needs to sounds like "It is 9:45". Not "It is.....9.....40.....5"!
It looks (sounds?) like I'm going to have to record a sound bite for every minute of the day. I don't need to concern myself with AM and PM, so 12 hours will do. That's only
720 files. Yikes!
I jumped back into GarageBand and started to put the sound bites together. Here is “it is", "9", "40", "5" arranged side-by-side to form a sentence.
I then exported it as an MP3 and tried it again. What a difference! This is how I'm going to have to do it.
I named the files "100.mp3" for 1:00, "101.mp3" for 1:01...all the way up to "1259.mp3" for 12:59. It took me 4.5 hours to create and export all 720 sound bites. The files are tiny; about 70K. They only take up 100MB on my paltry 4GB micro USB card. And I thought I'd need to buy a bigger stick for this project!
With the sound bites ready to go, it was time to see if I could get my prototype to tell me the time.
I added a DS3231 RTC to my breadboard and started popping in some code.
The easiest way to do it was to take the hours and minutes from the RTC and convert them to a string. Then play the MP3 file that matches that string
sprintf(timeString, "%d%d.mp3", hours, minutes);
So if the time was 9:45...."timeString" would be "945.mp3".
The plan is to have the clock annunciate the time on the hour, but if you want you can press a button at any time and it’ll tell you. I even put in some Easter eggs. When the clock hits midnight on New Year’s Eve, it’ll wish you a Happy Ne Year, for example. And then there’s 5 o’clock.
Now it's just a matter of adding some functionality to set the time and date. Oh man, the date! That’s another 365 sound bites!See this project from start to finish:
Adafruit's VS1053 MP3 Player Breakout
Talking Clock - Part I Talking Clock - Part II Talking Clock - Part III Talking Clock - Part IV Talking Clock - Part V Talking Clock - Part VI