zoukankan      html  css  js  c++  java
  • 用C#播放声音文件

    为了系统人性话,更加智能,有时候需要一些声音辅助系统
    下面这个例子可以播放指定音频文件,而且还可以读字符串:

    /// <summary>

            /// 播放声音文件

            /// </summary>

            /// <param name="FileName">文件全名</param>

            public void PlaySound(string FileName)

            {//要加载COM组件:Microsoft speech object Library

                if (!System.IO.File.Exists(FileName))

                {

                    return;

                }

                SpeechLib.SpVoiceClass pp = new SpeechLib.SpVoiceClass();

     

                SpeechLib.SpFileStreamClass spFs = new SpeechLib.SpFileStreamClass();

     

                spFs.Open(FileName, SpeechLib.SpeechStreamFileMode.SSFMOpenForRead, true);

                SpeechLib.ISpeechBaseStream Istream = spFs as SpeechLib.ISpeechBaseStream;

                pp.SpeakStream(Istream, SpeechLib.SpeechVoiceSpeakFlags.SVSFIsFilename);

                spFs.Close();

            }
  • 相关阅读:
    2019/1/2
    2018/12/22
    2018/12/18
    2018/12/17
    2018/12/16
    编程总结汇总
    学习总结汇总
    第十三周学习总结--助教
    第十一周编程总结
    第10周编程总结
  • 原文地址:https://www.cnblogs.com/longyi/p/1459779.html
Copyright © 2011-2022 走看看