Esempio n. 1
0
        public void Run()
        {
            var speaker = new SpVoice();
            VoiceType = NeoSpeechVoiceType.Anna;
            speaker.Voice = NeoSpeech.GetVoice(VoiceType);
            speaker.Rate = Rate;

            SpFileStream stream = new SpFileStream();
            try
            {
                stream.Format.Type = SpeechAudioFormatType.SAFT48kHz16BitStereo;
                stream.Open(FileName + ".wav", SpeechStreamFileMode.SSFMCreateForWrite, true);
                speaker.AudioOutputStream = stream;
                speaker.Speak(Text,SpeechVoiceSpeakFlags.SVSFlagsAsync);
                speaker.WaitUntilDone(Timeout.Infinite);
                stream.Close();
                Thread.Sleep(100);
                MP3Engine.Wav2Mp3(FileName + ".wav", FileName + ".mp3");
                System.IO.File.Delete(FileName + ".wav");
            }
            catch (System.Runtime.InteropServices.COMException ex)
            {
                stream.Close();
                throw ex;
            }
            finally
            {

            }
        }
Esempio n. 2
0
        public int EnqueueSpeech(string text, NeoSpeechVoiceType VoiceType, int speechRate, string filename)
        {
            lock (SpeechQueue)
            {
                SpeechTask task = new SpeechTask()
                {
                    Text = text,
                    VoiceType = VoiceType,
                    Rate = speechRate,
                    FileName = filename
                };

                SpeechQueue.Enqueue(task);

                return task.GetHashCode();
            }
        }
Esempio n. 3
0
 public static SpObjectToken GetVoice(NeoSpeechVoiceType voicetype)
 {
     return NeoSpeechVoices[voicetype];
 }
Esempio n. 4
0
 public int EnqueueSpeech(string text, NeoSpeechVoiceType voiceName, string filename)
 {
     return EnqueueSpeech(text, voiceName, 0, filename);
 }