使用Microsoft Speech Object Library自动朗读

C#代码如下:

using System;
using SpeechLib;

namespace TestConsole
{
    class Program
    {
        static void Main()
        {
            "已添加威妮华1408110307,128元,3个".Say();
            
            Console.ReadLine();
        }
    }
    static class MakeItTalk
    {
        public static void Say(this string s)
        {
            SpeechVoiceSpeakFlags flag = SpeechVoiceSpeakFlags.SVSFlagsAsync;
            SpVoice voice = new SpVoice();
            voice.Voice = voice.GetVoices(string.Empty, string.Empty).Item(0);
            voice.Rate = 0;
            voice.Volume = 100;
            voice.Speak(s, flag);
        }
    }
}

 

posted @ 2014-10-16 16:16  青松哥哥  阅读(1511)  评论(0编辑  收藏  举报