TTS语言 录音功能

首先添加命名空间和相关的代码,如下:

using System.Runtime.InteropServices;

 [DllImport("winmm.dll", EntryPoint = "mciSendString", CharSet = CharSet.Auto)]
        private static extern int mciSendString(
         string lpstrCommand,
         string lpstrReturnString,
         int uReturnLength,
         int hwndCallback
        );

        private static void mciSendString(String cmd)
        {
            mciSendString(cmd, "", 0, 0);
        }

        private static void StartRecord()
        {
            mciSendString("close movie");
            mciSendString("open new type WAVEAudio alias movie");
            mciSendString("record movie");
        }

        private static void StopRecord(string filename)
        {
            mciSendString("stop movie");
            mciSendString("save movie " + filename);
            mciSendString("close movie");
        }

 然后直接调用 StartRecord(),开始录音 StopRecord():停止录音

 

posted @ 2013-06-10 09:32  程序有Bug  阅读(485)  评论(0编辑  收藏  举报