2013年9月30日 星期一

voice語音要先灌SPSI5.4

 
   string fileNameWithOutExtention;
    string fileName;
 SpeechVoiceSpeakFlags flag = SpeechVoiceSpeakFlags.SVSFlagsAsync;
        SpVoice voice = new SpVoice();
        voice.Voice = voice.GetVoices(string.Empty, string.Empty).Item(1);

        //item(1) 英文女音
        //item(3) 中文男音
        //一個字接一個字
     
        string speakText = Session["CtValImg"].ToString();
        for (int s = 0; s < 4;s++ )
        {
            string c = speakText.Substring(s, 1);
            voice.Speak(c, flag);
            Thread.Sleep(200);
        }


// fileNameWithOutExtention = Guid.NewGuid().ToString();
        // fileName = @Server.MapPath("FileUpload/" + fileNameWithOutExtention + ".wav");
        //SpeechVoiceSpeakFlags flag = SpeechVoiceSpeakFlags.SVSFlagsAsync;
        //SpVoice voice = new SpVoice();
        //voice.Voice = voice.GetVoices(string.Empty, string.Empty).Item(1);

        //string readvoice = "";
        //for (int s = 0; s < 4; s++)
        //{
        //    readvoice += Session["CtValImg"].ToString().Substring(s, 1) + " ";
        //}
        //SpeechStreamFileMode SpFileMode = SpeechStreamFileMode.SSFMCreateForWrite;
        //SpFileStream SpFileStream = new SpFileStream();
        //SpFileStream.Open(fileName, SpFileMode, false);
        //voice.AudioOutputStream = SpFileStream;
        //voice.Speak(readvoice, flag);
        //voice.WaitUntilDone(Timeout.Infinite);
        //SpFileStream.Close();

        //if (File.Exists(fileName)) {
        //    File.Delete(fileName);        }

沒有留言:

張貼留言