Example Source Code

C# Example code to interface a Devantech SP03 Speech Synthesizer:

Example

using RoboticsConnection.Serializer;
using RoboticsConnection.Serializer.Ids;
using RoboticsConnection.Serializer.Sensors;
using RoboticsConnection.Serializer.Components;
using RoboticsConnection.Serializer.Controllers;
using System;

namespace test
{
	class Program
	{
		static Serializer serializer;
		static SP03 speaker;

		static void Main(string[] args)
		{
			serializer = new Serializer();
			speaker = new SP03(serializer);
			serializer.CommunicationStarted += new SerializerEventHandler(serializer_CommunicationStarted);

			serializer.Run();
		}

		// Note: This will fire as soon as the .NET Library is communicating
		// with the Serializer.
		static void serializer_CommunicationStarted(Serializer sender)
		{            
			speaker.Speak("Danger Will Robinson, Danger!");
			speaker.SpeakCannedPhrase(4);  // speak pre-programmed phrase #4
		}
	}
}     


Last Updated: 3/16/2008