/// <summary> /// Executes a TTS sinchronously /// </summary> /// <param name="textToSay">text to speech out</param> /// <returns>true if provided text was spoken, false otherwise</returns> protected abstract bool Speak(SpeechTextTask speechTask);
/// <summary> /// Executes a TTS sinchronously /// </summary> /// <param name="textToSay">text to speech out</param> /// <returns>true if provided text was spoken, false otherwise</returns> protected override bool Speak(SpeechTextTask speechTask) { bool locked; if (speechSynth == null) return false; if (speechTask == null) return false; string original = speechTask.TTS; string tts = speechTask.TTS; //if (selectedVoiceName == "Susan") //{ // tts = tts.Replace("robot", "row-bought"); // tts = tts.Replace("_", " "); // tts = tts.Replace("stop", "stup"); //} for (int i = 0; i < this.pronunciation.Count; ++i) { tts = this.pronunciation[i].ReplaceWordByPronunciation(tts); } //if (!Monitor.TryEnter(speechSynth)) // return false; //locked = true; //Speaking = true; SpokenString = original; speechTask.Status = SpeechTextTaskStatus.Speaking; lastSpeechResult = SpeakOperationResult.Error; try { OnSpeakStarted(tts); if (speechSynth.Voice != selectedVoiceName) speechSynth.Voice = selectedVoiceName; speechSynth.Language = "EnglishUs"; speechSynth.Read(tts); //Monitor.Wait(speechSynth); //Monitor.Exit(speechSynth); //locked = false; } catch { //if (locked) // Monitor.Exit(speechSynth); ////Speaking = ((speechSynth.State == SynthesizerState.Speaking) || (speechQueue.Count != 0)); //Speaking = (speechQueue.Count != 0); speechTask.Status = SpeechTextTaskStatus.CompleteFailed; return false; } //speechTask.Status = (lastSpeechResult == SpeakOperationResult.Succeeded) ? SpeechTextTaskStatus.CompletedSuccessfully : SpeechTextTaskStatus.CompleteFailed; //return (lastSpeechResult == SpeakOperationResult.Succeeded); speechTask.Status = SpeechTextTaskStatus.CompletedSuccessfully; return true; }
/// <summary> /// Enqueues provided SpeechTextTask to perform a TTS asinchronously /// </summary> /// <param name="textToSay">SpeechTextTask cotaining the text to speech out</param> /// <returns>true if provided text was enqueued, false otherwise</returns> public virtual bool SpeakAsync(SpeechTextTask task) { if (task == null) return false; //if (speechQueue.Count >= speechQueue.Capacity) // return false; speechQueue.Produce(task); return true; }
/// <summary> /// Enqueues provided SpeechTextTask to perform a TTS asinchronously /// </summary> /// <param name="textToSay">SpeechTextTask cotaining the text to speech out</param> /// <returns>true if provided text was enqueued, false otherwise</returns> public override bool SpeakAsync(SpeechTextTask task) { if (speechSynth == null) return false; return base.SpeakAsync(task); }