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 { } }
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(); } }
public static SpObjectToken GetVoice(NeoSpeechVoiceType voicetype) { return NeoSpeechVoices[voicetype]; }
public int EnqueueSpeech(string text, NeoSpeechVoiceType voiceName, string filename) { return EnqueueSpeech(text, voiceName, 0, filename); }