下面这个例子可以播放指定音频文件,而且还可以读字符串:
/// <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();
        }
                    
                
                
            
        
浙公网安备 33010602011771号