How to convert text string to speech sound

后端 未结 6 681
無奈伤痛
無奈伤痛 2020-12-07 14:12

I am looking for a way to convert text(string) in ENG to speech(sound) in c#. do anyone know for a way or some open-source lib that can help me with this task?

6条回答
  •  无人及你
    2020-12-07 14:44

    You can do this with the help of System.Speech.Synthesis namespace. For that, you need to add a reference to System.speech.dll first.

    Try this:

    using System.Speech.Synthesis;
    
    namespace TextToSpeech
    {
       public partial class Form1 : Form
       {
         SpeechSynthesizer speak;
         public Form1()
         {
            InitializeComponent();
            speak = new SpeechSynthesizer();
         }
    
         private void button1_Click(object sender, EventArgs e)
         {
            string text="Speak this";
            speak.SpeakAsync(text);
         }
      }
    }
    

提交回复
热议问题