Add Speech to an application Fast! (Works on Windows Server 8)

Keywords: C#,  Text to Speech , TTS, Microsoft. Free.

You can adjust voice as well, but this is plain jane and simple.

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Speech;
using System.Speech.Synthesis;
//using Microsoft.Speech.Synthesis; –error for some reason even when using another thread.
namespace KinectDemo
{
      public class SpeechWrapper
     {
         private SpeechSynthesizer MySynth { get; set; }
         public Action Say { get; set; }
         public SpeechWrapper()
        {
           MySynth = new SpeechSynthesizer();
          MySynth.Rate = -4;
          MySynth.SelectVoiceByHints(VoiceGender.Male, VoiceAge.Child);
          MySynth.Volume = 100;
          Say = ((input) =>
         {
               MySynth.Speak(input);
         });
       }
   }
}

Implementation:

public property:
public SpeechWrapper VoiceOfTheOne { get; set; }

Set Value: VoiceOfTheOne = new SpeechWrapper();

Say Something is easy now:VoiceOfTheOne.Say(“Welcome to Augmented Reality By Daniel Turnell and Mark Rowe”);

Share on Facebook

Leave a Reply

Your email address will not be published.