微软TTS Demo

1、引用 System.Speech

2、代码示例

static void Main(string[] args)
    {
        var synthesizer = new SpeechSynthesizer();
        synthesizer.SetOutputToDefaultAudioDevice();
        synthesizer.SetOutputToWaveFile(@"D:\tts\en_1.wav");
        synthesizer.Speak("All we need to do is to make sure we keep talking");
        Console.WriteLine("Finish");
        var content = File.ReadAllText(@"D:\tts\v.txt", Encoding.UTF8);

        synthesizer.SelectVoice("Microsoft Huihui Desktop");
        synthesizer.SetOutputToWaveFile(@"D:\tts\cn_1.wav");
        synthesizer.Speak("你好,早上好,");
        synthesizer.SetOutputToWaveFile(@"D:\tts\cn_2.wav");
        synthesizer.Speak(content);
        Console.WriteLine("Press any key to exit...");
        Console.ReadKey();
    }

 

posted @ 2020-06-29 11:51  向萧  阅读(591)  评论(0编辑  收藏  举报