Yet Another Billy Bass modification
.
Introduction
The general idea is to make the singing fish Billy Bass the voice of the house, babbling out home automation data, weather forecasts, news and other stuff I come up with. I intend not to use prerecorded sounds, but instead let Billy (=the mbed) download things to say in form of wav-files from the home server.
This approach needs some form of IoT (Internet of Things) or WoT (Web of Things) ideology, because the nodes (server and mbed) needs to be able to communicate without direct user interaction.
It sure would be very nice to have fish on the wall babbling out all sorts of stuff all day, even when no-one's at home :). Have to remember to program him to be quiet at night.
Home server
Home automation (e.g. wav generation, image and video data) and other stuff require more computing power and storage than embedded systems can provide, so a pc-based server is required. It will be an Ubuntu Linux in server mode, as I already have one. The server will generate wav-files for Billy to say using Festivals' text2wave program. This is because there are no online services that provide wav generation in finnish. I haven't tested if the generated wav-files are in the right format for playing on the mbed.
Making sound files with Festivals text2wave gives Billy a somewhat dry and monotonic voice, but I'll have to make do until something better comes up.
The server has to be able to notify the mbed in some way that there is new stuff ready for playing every time the server has generated something new.
Billy (and the mbed)
Billy will get a brain transplant in the form of the mbed (as the other example on this site), which will be in charge of operations, ie. moving the fish and playing sounds.
The plan is to get the mbed to download the sound to play to its sd card memory from the home server, when the server notifies that there is something new to play. This could be done running a http server on the mbed, which could receive notifications from the server.
This means the mbed will need to run both a http server (for receiving notifications) and a client (for downloading sounds) at the same time.
I have no idea of how to implement some sort of lip-synch based on the soudn files for the fish yet.
All this sounds to be quite a lot of work for the mbed. Too much?
All kind of ideas, thougths, advice and comments are welcome!
Project update, Jan. 24, 2010
My Billy Bass brain surgery project is proceeding according to plan. I finally got my L293D motor control chip (ordered from England via Ebay) and a 1 GB Transcend microSD card with a miniSD and regular SD adapter. I used the miniSD adapter as a fancy breakout box for the breadboard, so I can use the regular when checking out the card in my laptop.
Ethernet is also working with the help of a RJ-45 jack robbed from an old network card. Here is the setup so far (click on the image for a bigger version):
As you can see, I'm an expert in soldering :) The miniSD adapter was a pain to solder. The miniSD (and micro and regular) pin layout can be found here. The RJ-45 connector is held in place with a rubber band, and as you also can see, it's been a while since I last used my breadboard (a 'little' dusty, eh?). Here's a closer look from the other side (click on the image for a bigger version):
As for the coding, I've been able to put together a program that connects to the Internet and downloads a wav-file and stores it on the sd card. I used the excellent examples found in the cookbook on how to use httpclient and writing to the sd card.
So far everything has gone very smooth thanks to the advice from forum members, the easy to understand examples of the cookbook and the easy to interface mbed itself.
Next task is to connect the L293D and make Billy move.
I ordered a ready made audio amp circuit via Ebay, and I'll try to make Billy speak when it arrives.
Project update, August 14, 2010
This project has come a long way since last update. Now Billy does what was planned (more or less successfully :) ), and he has transformed into Billy 'Frankenfish' Bass PSE where PSE stands for Power Saver Edition. The Frankenfish addition comes from the significantly enlarged circuit board that drives him. And the power saving comes from a relay circuit that turns the audio amps on and off when necessary (in earlier editions the amps were always on).
Billy's abilities
Reading the news
Billy reads out the daily news every day at 7.00 pm. This is done with some help from the home server that downloads an RSS feed from a domestic news site and parses out the news items. Then the server creates a wav-file from the text (using Festivals' text-to-speech) and puts it in a directory from where Billy can download the sound with his Httpclient. The server also creates a 'Billy Movement File, BMF' based on the text. The BMF file is simply a row of 0's and 1's, where a 1 is for every wovel and a 0 is for every other character (except for numbers which have their own number sequences depending on pronounciation).
The BMF file for the phrase 'Hello world!' would look like this: 01001001000. Space and special character codes as 0's.
Just as the wave sound the bmf file is put where Billy can download it.
After downloading the wave file and the bmf file Billy plays the sound using the renewed EA_wavplayer by Tom Coxon. At the same time a second ticker is started that feeds the bmf file data (the 0's and 1's) directly to the L293 DC motor driver chips inputs making Billy move his mouth in sync with the sound. Every 1 makes Billy's mouth open, and every 0 makes it close. Using this approach you get a satisfying quality lipsync after some fiddling with the ticker speed (as good as in dubbed movies) which is enough for me.
When playback is complete Billy notifies the server with a simple http get call to a php page that deletes the played sound from the server. The server then knows it is played and generates a new sound (and bmf file) to be played if there is something in queue in a Mysql database table.
Watching sauna temperatures
Because I live in Finland, which is the promised land of sauna (as you may have read in the news recently), Billy also calls out my sauna temperature changes every 10 degrees, starting at 40 degrees Celsius. This is because my sauna stove is heated with firewood (it has no electronics that I could hack into). Temperature readings are made by the home server using 1-wire sensors, and the speaking part is done just like the news part above.
Acting doorbell
Billy also works as a doorbell after I took apart the receiver unit (the one with the speaker) from a cheap wireless doorbell and bolted it on Billy's circuit board. When the doorbell button is pressed Billy sounds a 'ding-dong' sound which is stored on his SD card, and then he utters something like 'There's someone at the door, get up and open it!'. This sentence is also stored permanently on the SD card. The doorbell triggers an interruptIn that starts the sound (well, it actually just sets a flag, and then the main routine does the playing).
SMS-to-speech
Billy can also speak out SMS text messages sent to him. The messages actually go to the home server which has a mobile phone connected via serial port. The phone is operated by the Gnokii software.
Pictures and explanations (click on them to see 1200 pix versions)
The larger board is Billy 'Frankenfish' Bass's new brain. The small one on the right is the original brain. Talk about upgrade!
The sligthly elevated circuit board in the back corner is the audio amplifier circuit ripped from a computer speaker. It's great with volume control knob and all. You can see the audio output cable plug in front. The speaker element connects there. I found using unpluggable parts is very handy during debugging (it's easy to remove the board for inspection etc.).
The vertical positioned circuit board is from the doorbell receiver. I put it like that for better signal reception.
The Ethernet RJ-45 jack (robbed from an old network card) sits right beside the doorbell circuit.
You can also see that the mbed is cooled with a small fan. It's a 12 volt fan that runs on 5 volts for more quiet operation. The whole shabang is powered with an ac adapter taken from an ancient external HP cd burner. The ac adapter is great because it outputs both 12 volt and 5 volt voltages.
The SD 'breakout board' is in the front. It's simply an SD card adapter that houses the 2 GB microSD I use.
The beefy capacitors are needed for power reserve, because when the mbed activates the audio amp and the fish's DC motors at the same time it resets due to power lack without the two 3000uF caps.
The fish's motor cable connectors are beside the doorbell circuit. You can barely see the top of one of them behind the fan.
This is Billy's home: a vintage fishing creel ordered all the way from US via eBay(couldn't find one any closer). All components fit well inside the creel, and it's not too airtight for better cooling and ventilation. And it looks good on the shelf too. Power and network cables come out at the back (under the lid).
Here are all parts in the same picture. The speaker box is just a plastic foodstuff can which is not very good for audio quality, I have to try something better.
The tiny circuit in front is Billy's original brain.
Fried parts so far
Even though I suck at soldering and have a very vague understanding of analog electronics I have only managed to fry one microSD card so far (knock, knock). The SD cards seem to be very sensitive to voltage peaks.
Other problems
Darn, C++ is hard to master..
Future plans
Add tons of stuff to Billy's repertoire (after getting the basic stuff to work..).
The program
Here's the program. Feel free to look/use/copy/improve/other at your own risk.
7 comments
You need to log in to post a comment
Good stuff! Lets get that L293D into action and billy will be alive!