public static void Speak(string text, string filePath, Settings settings, AudioLibPCMFormat PCMFormat) { try { if (m_Tts != null && m_Tts.IsSynthesizerSpeaking) { if (!string.IsNullOrEmpty(filePath)) { return; } else { m_Tts.PauseAndDispose(); } m_Tts = null; } m_Settings = settings; if (m_SpeechWorker != null) { m_SpeechWorker.DoWork -= new System.ComponentModel.DoWorkEventHandler(m_SpeechWorker_DoWork); } m_SpeechWorker = new System.ComponentModel.BackgroundWorker(); if (m_Tts == null) { InitializeTTS(settings, PCMFormat); } List <string> inputStrings = new List <string>(); inputStrings.Add(text); inputStrings.Add(filePath); if (string.IsNullOrEmpty(filePath)) { m_SpeechWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(m_SpeechWorker_DoWork); m_SpeechWorker.RunWorkerAsync(inputStrings); } else { GenerateSpeech(inputStrings); } } catch (System.Exception ex) { Console.WriteLine(ex.ToString()); } }
public static void TestVoice(string text, string voice, Settings settings) { AudioLib.AudioLibPCMFormat audioFormat = new AudioLibPCMFormat((ushort)settings.Audio_Channels, (uint)settings.Audio_SampleRate, (ushort)settings.Audio_BitDepth); m_Tts = new TextToSpeech(audioFormat); m_Tts.SpeakString(voice, text, null); }
public static void InitializeTTS(Settings settings, AudioLibPCMFormat PCMFormat) { m_Settings = settings; m_Tts = new TextToSpeech(PCMFormat); }