public static void addSpeech(Elite.MessageBus messageBus, string text, string voice) { Elite.Speech newMessage = new Elite.Speech(); newMessage.text = text; newMessage.voice = voice; messageBus.spokenAnnouncements.Add(newMessage); }
public static void speak(Elite.MessageBus messageBus) { SpeechSynthesizer reader = new SpeechSynthesizer(); while (true) { if (messageBus.spokenAnnouncements.Count > 0) { try { Elite.Speech message = messageBus.spokenAnnouncements[0]; messageBus.spokenAnnouncements.RemoveAt(0); if (message.voice != null && message.voice != "") { try { reader.SelectVoice(message.voice); } catch { Debug.Write("Error: Unable to set voice: " + message.voice); } } reader.SetOutputToDefaultAudioDevice(); reader.Speak(message.text); Thread.Sleep(1500); } catch (Exception ex) { Debug.Write(ex.ToString()); } } else { Thread.Sleep(250); } } }