Using Active TTS in C#

Active TTS is a standard COM component that is supported by .Net framework.

 

Here is a step by step example of using Active TTS in a C# winform project with VS2003.

1. Create a C# winform project by using the IDE wizard.

2. Add reference to TTSObj.dll by clicking main menu item, Project->Add Reference, pop up the dialog, choose “COM” tab, click the “browse” button to pick up the TTSobj.dll (You can find it in the default Active TTS installation folder which is C:Program FilesActive TTS).  

activetts.jpg

  Click OK, you will find TTSObj name space in your solution explorer.  

solutiontts.jpg

  3. Now you can use Active TTS object like a normal C# class in your code.  For a working demo, please look into the DemoCSharp in the trial package. 

You can see how easy it is to incorporate the text to mp3 function in your application.

            ttsObj = new CTextToSpeechClass();

            comboBox1.Items.Clear();
            for(int i = 0; i < ttsObj.VoiceCount; i++)
            {
                comboBox1.Items.Add(ttsObj.GetVoiceName(i));
            }
            comboBox1.SelectedIndex = 0;
            ttsObj.VoiceIdx = comboBox1.SelectedIndex;

            ttsObj.OnTTSEnd += new _ITextToSpeechEvents_OnTTSEndEventHandler(ttsObj_OnTTSEnd);
            ttsObj.OnTTSStart += new _ITextToSpeechEvents_OnTTSStartEventHandler(ttsObj_OnTTSStart);
            ttsObj.OnTTSProgress += new _ITextToSpeechEvents_OnTTSProgressEventHandler(ttsObj_OnTTSProgress);
            ttsObj.OnTTSWord += new _ITextToSpeechEvents_OnTTSWordEventHandler(ttsObj_OnTTSWord);