private async Task DoSay(string actualPhrase) { var bitchName = _settingAgent.GetSetting("BitchName", Constants.DefaultBitchName); var newGuid = Guid.NewGuid(); _eventHub.InvokeStartTalkingEvent(newGuid, bitchName, actualPhrase); var task = new Task(() => { var builder = new PromptBuilder(); builder.StartSentence(); builder.AppendText(actualPhrase); builder.EndSentence(); using (var synthesizer = new SpeechSynthesizer()) { var voices = synthesizer.GetInstalledVoices(); var voice = voices.LastOrDefault(x => x.VoiceInfo.Gender == VoiceGender.Female); if (voice == null) { voice = voices.FirstOrDefault(); } if (voice == null) { throw new InvalidOperationException("Cannot find any installed voices."); } //synthesizer.SelectVoice("Microsoft David Desktop"); //synthesizer.SelectVoice("Microsoft Hazel Desktop"); //synthesizer.SelectVoice("Microsoft Zira Desktop"); synthesizer.SelectVoice(voice.VoiceInfo.Name); synthesizer.Speak(builder); } }); task.Start(); await task; _eventHub.InvokeDoneTalkingEvent(newGuid); }