Voice Activated Toaster

I have played around with both the Speech API and the Phidget API over the last 5-7 years or so.  For the speech API, I created a home automation system to use the speech engine to control a house’s sound system, a cook’s recipe system, and to read the news and weather to a causal listener.  If patents weren’t $10,000, I would have sent something in – my neighbor in Alexandria worked at the Patent Office and thought it had a good chance to get approved, but I digress.  For the Phidget API, I did something similar to Brian Peek’s animated light show on Coding-4-Fun’s where I synched my Christmas’s lights to music.

I recently got back into both APIs to build a voice-activated toaster.  I plan to expand the project to include mocking of these external dependencies (the Phidget board/Toaster and the speech engine). 

To build the connection to the toaster, I used the Phidget 0/0/4 Interface kit.  I then wired it up like Brian did:

To handle the voice input, I used a cheap wireless microphone system from radio shack and hooked it into my microphone port. 

I used an old toaster that was hanging around my attic.

 I then slapped up a quick console application.  The application creates a connection to the Phidget board, starts up a speech recognition engine and listens for the word “Toast”.  Once recognized, the Phidget channel opens and the toaster is activated.  Once the word “Stop” is heard, the toaster is deactivated.

Here is the console output:

and here is the toaster in action:


I recognize that the code is not ready for prime time (heck, does not even have error handling), but I wanted to get a working skeleton down before throwing in my unit tests and mocking framework.  There will be more on that next week.  Here are the 80 lines of code that I needed to write to get it working:


namespace Com.Tff.VoiceActivatedToaster


    class Program


        private static InterfaceKit interfaceKit = null;


        static void Main(string[] args)








        private static void CreateSpeechRecognitionEngine()


            SpeechRecognitionEngine speechRecognitionEngine = new SpeechRecognitionEngine();


            Choices choices = new Choices();



            Grammar grammar = new Grammar(choices);




            speechRecognitionEngine.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(speechRecognitionEngine_SpeechRecognized);


            Console.WriteLine("Computer is listening");



        static void speechRecognitionEngine_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)


            Console.WriteLine("{0} was recognized with {1} confidence", e.Result.Text, e.Result.Confidence.ToString());

            if (e.Result.Text == "Toast")


                interfaceKit.outputs[0] = true;



            if (e.Result.Text == "Stop")


                interfaceKit.outputs[0] = false;




        private static void CreatePhigitInterface()


            interfaceKit = new InterfaceKit();








Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: