private void SpeakEndOfGameInfo(bool isNewHighscore) { PromptBuilder promptBuilder = new PromptBuilder(); promptBuilder.StartStyle(new PromptStyle() { Emphasis = PromptEmphasis.Reduced, Rate = PromptRate.Slow, Volume = PromptVolume.ExtraLoud }); promptBuilder.AppendText("Game Over"); promptBuilder.EndStyle(); if (isNewHighscore) { promptBuilder.AppendBreak(TimeSpan.FromMilliseconds(500)); promptBuilder.StartStyle(new PromptStyle() { Emphasis = PromptEmphasis.Moderate, Rate = PromptRate.Medium, Volume = PromptVolume.Medium }); promptBuilder.AppendText("new high score:"); promptBuilder.AppendBreak(TimeSpan.FromMilliseconds(200)); promptBuilder.AppendTextWithHint(CurrentScore.ToString(), SayAs.NumberCardinal); promptBuilder.EndStyle(); } SpeechSynthesizer.SpeakAsync(promptBuilder); }
public static bool CreateWavConvertToMp3File(string trgWavFile, string text) { var ps = new PromptStyle { Emphasis = PromptEmphasis.Strong, Volume = PromptVolume.ExtraLoud }; //pStyle.Rate = PromptRate.Fast; var pb = new PromptBuilder(); pb.StartStyle(ps); pb.StartParagraph(); pb.StartVoice(VoiceGender.Female, VoiceAge.Child); pb.StartSentence(); pb.AppendBreak(TimeSpan.FromSeconds(.3)); // removed on Sep 26, 2011 // reesotred Jun 2013 pb.AppendText(text, PromptRate.Medium); pb.AppendBreak(TimeSpan.FromSeconds(.3)); // removed on Sep 26, 2011 // reesotred Jun 2013 pb.EndSentence(); pb.EndVoice(); pb.EndParagraph(); pb.EndStyle(); var tempWav = trgWavFile + ".WAV"; using (var speaker = new SpeechSynthesizer()) { //speaker.Speak(pbuilder); // if (File.Exists(file)) File.Delete(file); // added Delete() on Sep 26, 2011. using (var fileStream = new FileStream(tempWav, FileMode.Create)) { try { speaker.Volume = 100; speaker.SetOutputToWaveStream(fileStream); // // speaker.SetOutputToWaveFile(tempWav); speaker.Speak(pb); //nogo: this makes annoying beep and place it instead of the TTS message : using (var writer = new BinaryWriter(fileStream)) { new WaveFun.WaveGenerator(WaveFun.WaveExampleType.ExampleSineWave).Save_NotClose(writer); writer.Close(); } catch (Exception ex) { ex.Log(); } finally { speaker.SetOutputToDefaultAudioDevice(); fileStream.Close(); } } } NAudioHelper.ConvertWavToMp3(tempWav, trgWavFile); try { File.Delete(tempWav); } catch (Exception ex) { ex.Log(); } return(true); }
protected override void HandleNotification(Notification notification, string displayName) { /* * string xml = @"<p> * <s>You have 4 new messages.</s> * <s>The first is from Stephanie Williams and arrived at <break/> 3:45pm. * </s> * <s> * The subject is <prosody rate=""-20%"">ski trip</prosody> * </s> * </p>"; * */ PromptBuilder pb = new PromptBuilder(); // handle title if (notification.CustomTextAttributes != null && notification.CustomTextAttributes.ContainsKey("Notification-Title-SSML")) { pb.AppendSsmlMarkup(notification.CustomTextAttributes["Notification-Title-SSML"]); } else { pb.AppendText(notification.Title, PromptEmphasis.Strong); } pb.AppendBreak(); // handle text if (notification.CustomTextAttributes != null && notification.CustomTextAttributes.ContainsKey("Notification-Text-SSML")) { pb.AppendSsmlMarkup(notification.CustomTextAttributes["Notification-Text-SSML"]); } else { pb.AppendText(notification.Description); } try { ss.Speak(pb); } catch (Exception ex) { Growl.CoreLibrary.DebugInfo.WriteLine("Unable to speak input: " + ex.Message); // fall back to plain text (if the plain text is what failed the first time, it wont work this time either but wont hurt anything) pb.ClearContent(); pb.AppendText(notification.Title, PromptEmphasis.Strong); pb.AppendBreak(); pb.AppendText(notification.Description); ss.Speak(pb); } }
PromptBuilder MakeSpeech(IEnumerable<ProjectStatus> projects, string rawSentence) { var promptBuilder = new PromptBuilder(); if (string.IsNullOrEmpty(rawSentence)) return promptBuilder; promptBuilder.AppendBreak(OneSecond); foreach (var project in projects) { promptBuilder.AppendBreak(OneSecond); promptBuilder.AppendText(_speechTextParser.Parse(rawSentence, project)); } return promptBuilder; }
private static void Testing_AppendTextWithHint() { var builder = new PromptBuilder(); builder.AppendTextWithHint("3rd", SayAs.NumberOrdinal); builder.AppendBreak(); builder.AppendTextWithHint("3rd", SayAs.NumberCardinal); builder.AppendBreak(); builder.AppendBookmark("First bookmark"); builder.AppendBreak(); builder.AppendTextWithPronunciation("DuBois", "duˈbwɑ"); builder.AppendBreak(); synthesizer.Speak(builder); }
///<remarks>Метод. Конец игры.</remarks> private void GameOver() { timer.Stop(); isGameOver = true; /* * bdrEndOfGame.Visibility = Visibility.Visible; * tbFinalScore.Text = score.ToString(); */ PromptBuilder promptBuilder = new PromptBuilder(); promptBuilder.StartStyle(new PromptStyle() { Emphasis = PromptEmphasis.Reduced, Rate = PromptRate.Slow, Volume = PromptVolume.ExtraLoud }); promptBuilder.AppendText("оооо неееееет"); promptBuilder.AppendBreak(TimeSpan.FromMilliseconds(200)); promptBuilder.AppendText("я мертвааааа"); promptBuilder.EndStyle(); speechSynthesizer.SpeakAsync(promptBuilder); MessageBox.Show("Количество очков " + score.ToString() + ".\nЧтобы начать новую игру нажмите пробел.", "Потрачено", MessageBoxButton.OK, MessageBoxImage.Hand); }
void RecEngine_SpeechRecognized(object sender, SpeechRecognizedEventArgs e) { switch (e.Result.Text) { case "hello there": PromptBuilder pBuilder = new PromptBuilder(); pBuilder.StartSentence(); pBuilder.AppendText("Hello Kola"); pBuilder.EndSentence(); pBuilder.AppendBreak(PromptBreak.Small); pBuilder.StartSentence(); pBuilder.AppendText("Hey Whats Up?", PromptEmphasis.Strong); pBuilder.EndSentence(); syn.SpeakAsync(pBuilder); richTextBox1.Text += "Hey Whats Up"; break; case "say my name": syn.SpeakAsync("Your name is Kola"); richTextBox1.Text += "\nYour name is kola"; break; case "Whats good?": syn.SpeakAsync("Not alot man, just here chilling!"); richTextBox1.Text += "\nNot alot man, just here chilling1"; break; case "say text": syn.SpeakAsync(richTextBox1.Text); break; } //throw new NotImplementedException(); }
void recEngine_SpeechRecognized(object sender, SpeechRecognizedEventArgs e) { switch (e.Result.Text) { case "ivan": PromptBuilder builder = new PromptBuilder(); builder.StartSentence(); builder.AppendText("Poquemon tipo Morro, Este poquemon habita en el Cetis 16.", PromptEmphasis.Reduced); builder.EndSentence(); builder.AppendBreak(new TimeSpan(0, 0, 0, 0, 50)); builder.StartSentence(); builder.AppendText("pa' que quieres saber eso, jaja saludos", PromptEmphasis.Strong); builder.EndSentence(); synthesizer.SpeakAsync(builder); break; case "imprime mi nombre": richTextBox1.Text += "\nMisael"; break; case "habla el texto": synthesizer.SpeakAsync(richTextBox1.SelectedText); break; } }
private void RecEngine_SpeechRecognized(object sender, SpeechRecognizedEventArgs e) { switch (e.Result.Text) { case "say hello": PromptBuilder builder = new PromptBuilder(); builder.StartSentence(); builder.AppendText("Hello sir"); builder.EndSentence(); builder.AppendBreak(PromptBreak.ExtraSmall); builder.StartSentence(); builder.AppendText("How you doing?", PromptEmphasis.Strong); builder.EndSentence(); synthesizer.SpeakAsync(builder); break; case "print my name": richTextBox.Text += "\nName is = Subhojit"; break; case "Speak selected text": synthesizer.SpeakAsync(richTextBox.SelectedText); break; } }
static void PromptBuilding() { PromptBuilder builder = new PromptBuilder(); builder.StartSentence(); builder.AppendText("This is a prompt building example."); builder.EndSentence(); builder.StartSentence(); builder.AppendText("Now, there will be a break of 2 seconds."); builder.EndSentence(); builder.AppendBreak(new TimeSpan(0, 0, 2)); builder.StartStyle(new PromptStyle(PromptVolume.ExtraSoft)); builder.AppendText("This text is spoken extra soft."); builder.EndStyle(); builder.StartStyle(new PromptStyle(PromptRate.Fast)); builder.AppendText("This text is spoken fast."); builder.EndStyle(); SpeechSynthesizer synthesizer = new SpeechSynthesizer(); synthesizer.Speak(builder); synthesizer.Dispose(); }
void RecEngine_SpeechRecognized(object sender, SpeechRecognizedEventArgs e) { switch (e.Result.Text) { case "hola": PromptBuilder builder = new PromptBuilder(); builder.StartSentence(); builder.AppendText("Hola David."); builder.EndSentence(); builder.AppendBreak(new TimeSpan(0, 0, 0, 0, 50)); builder.StartSentence(); builder.AppendText("Como estas?", PromptEmphasis.Strong); builder.EndSentence(); synthesizer.SpeakAsync(builder); break; case "mostrar mi nombre": richTextBox1.Text += "\nDavid"; break; case "leeme el texto": synthesizer.SpeakAsync(richTextBox1.SelectedText); break; } }
void ExecutarFala(Tuple <FalaModel, Delegate, Delegate> falaTuple) { var model = falaTuple.Item1; var notificarBotCallback = falaTuple.Item2; var notificarErroBotCallback = falaTuple.Item3; _CallbackModel = new CallbackModel { ChannelName = BotAppSettings.ChannelName }; try { if (model == null) { _CallbackModel.Mensagem = $"Não consegui realizar a ação {EmotesConsts.NotLikeThis}"; notificarBotCallback?.DynamicInvoke(_CallbackModel); this.Falas.Remove(falaTuple); return; } var piada = _PiadaService.ObterPiadaAleatoria(); var promptBuilder = new PromptBuilder(new System.Globalization.CultureInfo("pt-BR")); promptBuilder.AppendText(piada.Pergunta); promptBuilder.AppendBreak(PromptBreak.Small); promptBuilder.AppendText(piada.Resposta); promptBuilder.AppendBreak(PromptBreak.Small); CallBackFalaFinalizada callback = new CallBackFalaFinalizada(FinalizarPiadaCallback); base.EncadeiaReacao = true; model.TextoPrompFala = promptBuilder; _CallbackModel.Mensagem = $"{piada.Pergunta} {piada.Resposta} {EmotesConsts.LUL} {EmotesConsts.Kappa}"; notificarBotCallback?.DynamicInvoke(_CallbackModel); base.ExecutarAudioSync(model, callbackFalaFinalizada: callback); } catch { this.IsExecutandoAudio = false; this.Falas.Remove(falaTuple); _CallbackModel.Mensagem = $"@daniel_dev Deu ruim ao fazer o comentário, ve o log aí {EmotesConsts.NotLikeThis}"; notificarErroBotCallback?.DynamicInvoke(_CallbackModel); } }
PromptBuilder MakeSpeech(IEnumerable <ProjectStatus> projects, string rawSentence) { var promptBuilder = new PromptBuilder(); if (rawSentence.IsEmpty()) { return(promptBuilder); } promptBuilder.AppendBreak(OneSecond); foreach (var project in projects) { promptBuilder.AppendBreak(OneSecond); promptBuilder.AppendText(_speechTextParser.Parse(rawSentence, project)); } return(promptBuilder); }
void promptSample() { var ps = new PromptStyle { Emphasis = PromptEmphasis.Strong, Volume = PromptVolume.ExtraLoud }; var pb = new PromptBuilder(); pb.StartStyle(ps); pb.StartParagraph(); pb.StartVoice(VoiceGender.Female, VoiceAge.Child); pb.StartSentence(); pb.AppendText($"Female Child", PromptRate.Medium); pb.AppendBreak(TimeSpan.FromSeconds(.3)); pb.EndSentence(); pb.EndVoice(); pb.StartVoice(VoiceGender.Female, VoiceAge.Senior); pb.StartSentence(); pb.AppendText($"Female Senior", PromptRate.Medium); pb.AppendBreak(TimeSpan.FromSeconds(.3)); pb.EndSentence(); pb.EndVoice(); pb.StartVoice(VoiceGender.Male, VoiceAge.Senior); pb.StartSentence(); pb.AppendText($"Male Senior", PromptRate.Medium); pb.AppendBreak(TimeSpan.FromSeconds(.3)); pb.EndSentence(); pb.EndVoice(); pb.StartVoice(VoiceGender.Male, VoiceAge.Child); pb.StartSentence(); pb.AppendText($"Male Child", PromptRate.Medium); pb.AppendBreak(TimeSpan.FromSeconds(.3)); pb.EndSentence(); pb.EndVoice(); pb.EndParagraph(); pb.EndStyle(); synth.SpeakAsyncCancelAll(); synth.SpeakAsync(pb); }
protected override void HandleNotification(Notification notification, string displayName) { /* string xml = @"<p> <s>You have 4 new messages.</s> <s>The first is from Stephanie Williams and arrived at <break/> 3:45pm. </s> <s> The subject is <prosody rate=""-20%"">ski trip</prosody> </s> </p>"; * */ PromptBuilder pb = new PromptBuilder(); // handle title if (notification.CustomTextAttributes != null && notification.CustomTextAttributes.ContainsKey("Notification-Title-SSML")) pb.AppendSsmlMarkup(notification.CustomTextAttributes["Notification-Title-SSML"]); else pb.AppendText(notification.Title, PromptEmphasis.Strong); pb.AppendBreak(); // handle text if (notification.CustomTextAttributes != null && notification.CustomTextAttributes.ContainsKey("Notification-Text-SSML")) pb.AppendSsmlMarkup(notification.CustomTextAttributes["Notification-Text-SSML"]); else pb.AppendText(notification.Description); try { ss.Speak(pb); } catch (Exception ex) { Growl.CoreLibrary.DebugInfo.WriteLine("Unable to speak input: " + ex.Message); // fall back to plain text (if the plain text is what failed the first time, it wont work this time either but wont hurt anything) pb.ClearContent(); pb.AppendText(notification.Title, PromptEmphasis.Strong); pb.AppendBreak(); pb.AppendText(notification.Description); ss.Speak(pb); } }
private void AppendBreak(int ms) { int ns = ms * 10000; pb.ClearContent(); pb.AppendBreak(new TimeSpan(ns)); synth.Speak(pb); pb.ClearContent(); }
//------------------------------------------------------------------------------------------------------------------- private void ProcessPhrase(PromptBuilder promptBuilder, string speech) { string[] paragraphs = speech.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); foreach (var paragraph in paragraphs) { promptBuilder.StartParagraph(); string[] sentences = paragraph.Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries); foreach (var sentence in sentences) { promptBuilder.StartSentence(); promptBuilder.AppendText(sentence); promptBuilder.EndSentence(); promptBuilder.AppendBreak(new TimeSpan(0, 0, 0, 0, SentencePause)); } promptBuilder.EndParagraph(); promptBuilder.AppendBreak(new TimeSpan(0, 0, 0, 0, ParagraphPause)); } promptBuilder.AppendBreak(new TimeSpan(0, 0, 0, 0, SpeechPause)); }
/// <summary> /// 获取当前验证码的语音提示 /// </summary> /// <param name="key">使用的键名</param> /// <returns></returns> public virtual MemoryStream GetAudioStream(string key) { // 检查是否支持 if (!SupportCaptchaAudio) { throw new NotSupportedException("TTS is unsupported on this environment"); } #if NETCORE throw new NotSupportedException("TTS is unsupported on .Net Core"); #else // 生成语音到内存 // 需要使用独立线程否则会提示当前线程不支持异步操作 // http://stackoverflow.com/questions/10783127/how-to-implement-custom-audio-capcha-in-asp-net var captcha = GetWithoutRemove(key) ?? ""; var stream = new MemoryStream(); var cultureInfo = Thread.CurrentThread.CurrentCulture; var thread = new Thread(() => { try { // 设置线程语言,语音提示会自动选择对应的语言 Thread.CurrentThread.CurrentCulture = cultureInfo; Thread.CurrentThread.CurrentUICulture = cultureInfo; // 构建语音 // 参数缓存一定时间,防止多次尝试攻击 var prompt = CaptchaAudioPromptCache.GetOrCreate(captcha, () => { var builder = new PromptBuilder(); var promptRates = new[] { PromptRate.Slow, PromptRate.Medium, PromptRate.Fast }; var voiceGenders = new[] { VoiceGender.Male, VoiceGender.Female, VoiceGender.Neutral }; var voiceAges = new[] { VoiceAge.Adult, VoiceAge.Child, VoiceAge.Senior, VoiceAge.Teen }; foreach (var c in captcha) { builder.StartVoice( RandomUtils.RandomSelection(voiceGenders), RandomUtils.RandomSelection(voiceAges)); builder.AppendText(c.ToString(), RandomUtils.RandomSelection(promptRates)); builder.AppendBreak(TimeSpan.FromMilliseconds(RandomUtils.RandomInt(50, 450))); builder.EndVoice(); } return(builder); }, CaptchaAudioPromptCacheTime); // 写入语音到数据流 var synthesizer = new SpeechSynthesizer(); synthesizer.SetOutputToWaveStream(stream); synthesizer.Speak(prompt); } catch (Exception e) { var logManager = Application.Ioc.Resolve <LogManager>(); logManager.LogError(e.ToString()); } }); thread.Start(); thread.Join(); stream.Seek(0, SeekOrigin.Begin); return(stream); #endif }
public static void QueueSilence(string[] args) { int duration; if (args == null || args.Length < 1 || !int.TryParse(args[0], out duration)) { return; } promptBuilder.AppendBreak(TimeSpan.FromMilliseconds(duration)); }
protected override void HandleNotification(Notification notification, string displayName) { StringBuilder sb = new StringBuilder(); PromptBuilder pb = new PromptBuilder(); pb.AppendText(notification.Title, PromptEmphasis.Strong); pb.AppendBreak(); pb.AppendText(notification.Description); ss.Speak(pb); }
private void Button1_Click(object sender, RoutedEventArgs e) { words = hyphenator.HyphenateText(InputTextBox.Text).Split(' '); int metronome1Notes, metronome2Notes; if (int.TryParse(Meter1Notes.Text, out metronome1Notes) && int.TryParse(Meter2Notes.Text, out metronome2Notes)) { int notes = LCM(metronome1Notes, metronome2Notes); List <int> beat = new List <int>(); for (int i = 0; i < notes; ++i) { if (i % metronome1Notes == 0 || i % metronome2Notes == 0) { beat.Add(i); } } List <TimeSpan> space = new List <TimeSpan>(); for (int i = 0; i < beat.Count - 1; ++i) { space.Add(new TimeSpan(defaultTimeSpan * (beat[i + 1] - beat[i]))); } space.Add(new TimeSpan(defaultTimeSpan * (notes - beat[beat.Count - 1]))); PromptBuilder promptBuilder = new PromptBuilder(); PromptStyle promptStyle = new PromptStyle(); promptStyle.Volume = PromptVolume.Soft; promptStyle.Rate = PromptRate.Medium; promptBuilder.StartStyle(promptStyle); // Not the best at splitting but it works // P E O P L E words = hyphenator.HyphenateText(InputTextBox.Text).Split(' '); int timespanIndex = 0; foreach (string s in words) { promptBuilder.AppendText(s); promptBuilder.AppendBreak(space[timespanIndex++]); if (timespanIndex >= space.Count()) { timespanIndex = 0; } } promptBuilder.EndStyle(); speechSynthesizer.SpeakAsync(promptBuilder); } }
public static void Speak(string FinalTextString) { if (reader.State == SynthesizerState.Paused) { tempReader.SpeakAsyncCancelAll(); tempReader.SpeakAsync("TTS is in Pause State. Please Press Caps lock E to continue with TTS"); Console.WriteLine("End of Speach "); } else { PromptBuilder pb2 = new PromptBuilder(new System.Globalization.CultureInfo("en-US")); // string str2 = "<say-as interpret-as=\"characters\">" + dataReceived + "</say-as>"; //pb2.AppendSsmlMarkup(FinalTextString); if (FinalTextString.Contains("asteriklinebreakasterik")) //split string at lineBreak and append break { string[] lineBreak = new string[] { "asteriklinebreakasterik" }; string[] result = FinalTextString.Split(lineBreak, StringSplitOptions.RemoveEmptyEntries); foreach (string v in result) { string[] pauses = new string[] { "\r\n" }; string[] pausesResult = v.Split(pauses, StringSplitOptions.RemoveEmptyEntries); foreach (var r in pausesResult) { pb2.AppendText(r); pb2.AppendBreak(PromptBreak.Small); } pb2.AppendBreak(TimeSpan.FromSeconds(2)); } reader.SpeakAsync(pb2); } else { reader.SpeakAsync(FinalTextString); } Console.WriteLine("End of Speach "); } }
public override bool Apply(PromptBuilder builder) { String argument = ParseTagArgument(); double duration; if (!Double.TryParse(argument, out duration)) { return false; } int pauseInTicks = (int) Math.Round(duration*TicksPerSecond); builder.AppendBreak(new TimeSpan(pauseInTicks)); return true; }
public Window1() { InitializeComponent(); SpeechSynthesizer synthesizer = new SpeechSynthesizer(); PromptBuilder promptBuilder = new PromptBuilder(); promptBuilder.AppendTextWithHint("WPF", SayAs.SpellOut); promptBuilder.AppendText("sounds better than WPF."); // Pause for 2 seconds promptBuilder.AppendBreak(new TimeSpan(0, 0, 2)); promptBuilder.AppendText("The time is"); promptBuilder.AppendTextWithHint(DateTime.Now.ToString("hh:mm"), SayAs.Time); // Pause for 2 seconds promptBuilder.AppendBreak(new TimeSpan(0, 0, 2)); promptBuilder.AppendText("Hey Sam, can you spell queue?"); promptBuilder.StartVoice("Microsoft Sam"); promptBuilder.AppendTextWithHint("queue", SayAs.SpellOut); promptBuilder.EndVoice(); promptBuilder.AppendText("Do it faster!"); promptBuilder.StartVoice("Microsoft Sam"); promptBuilder.StartStyle(new PromptStyle(PromptRate.ExtraFast)); promptBuilder.AppendTextWithHint("queue", SayAs.SpellOut); promptBuilder.EndStyle(); promptBuilder.EndVoice(); // Speak all the content in the PromptBuilder synthesizer.SpeakAsync(promptBuilder); }
void recEngine_SpeechRecognized(object sender, SpeechRecognizedEventArgs e) { if (e.Result.Text == "Jarvis") { Choices commands = new Choices(); commands.Add(new String[] { "notepad", "mycomputer", "music", "Speak" }); gBuilder = new GrammarBuilder(); gBuilder.Append(commands); grammer = new Grammar(gBuilder); recEngine.LoadGrammarAsync(grammer); synthesizer.SpeakAsync("Yes Sir"); } switch (e.Result.Text) { case "notepad": Process.Start("notepad"); break; case "mycomputer": Process.Start("explorer"); break; case "music": WMPLib.WindowsMediaPlayer wplayer = new WMPLib.WindowsMediaPlayer(); wplayer.URL = @"C:\\Users\\Yogesh\\Downloads\\Music\\Main Koi Aisa Geet Gaoon(MyMp3Song).mp3"; wplayer.controls.play(); break; case "Speak": PromptBuilder builder = new PromptBuilder(); //builder.StartStyle(new PromptStyle()); // builder.StartVoice(VoiceGender.Male, VoiceAge.Adult, 2); builder.StartSentence(); builder.AppendText("Hello Yogesh"); builder.EndSentence(); builder.AppendBreak(PromptBreak.None); builder.StartSentence(); builder.AppendText("How are You", PromptEmphasis.Strong); builder.EndSentence(); synthesizer.SpeakAsync(builder); break; } }
public override bool Apply(PromptBuilder builder) { String argument = ParseTagArgument(); double duration; if (!Double.TryParse(argument, out duration)) { return(false); } int pauseInTicks = (int)Math.Round(duration * TicksPerSecond); builder.AppendBreak(new TimeSpan(pauseInTicks)); return(true); }
public void speak(List <string> words, int rate = 0) { speaking = true; using (nowUsingSynthesizer = new SpeechSynthesizer()) { nowUsingSynthesizer.Rate = rate; var promptBuilder = new PromptBuilder(); foreach (var w in words) { promptBuilder.AppendText(w); promptBuilder.AppendBreak(); } nowUsingSynthesizer.Speak(promptBuilder); } speaking = false; }
private static void SayHello() { Console.WriteLine("Hello!"); synthesizer.SelectVoice(voices[2].VoiceInfo.Name); synthesizer.Rate = 2; promptBuilder.StartSentence(); promptBuilder.AppendText("Hello, Eugene!"); promptBuilder.EndSentence(); promptBuilder.AppendBreak(new TimeSpan(0, 0, 0, 0, 10)); promptBuilder.StartSentence(); promptBuilder.AppendText("How are you today?", PromptEmphasis.Strong); promptBuilder.EndSentence(); synthesizer.SpeakAsync(promptBuilder); }
public void Speak(string culture, string textToSpeak) { var tokens = textToSpeak.Split(new[] { '/' }); var prompt = new PromptBuilder(); prompt.StartVoice(CultureInfo.GetCultureInfo(culture)); foreach (var token in tokens) { prompt.AppendText(token); prompt.AppendBreak(); } prompt.EndVoice(); Synthesizer.SpeakAsync(prompt); }
private PromptBuilder BuildPrompt(string text) { PromptBuilder prompt = new PromptBuilder(); prompt.StartVoice(_synthesizer.Voice); prompt.EndVoice(); prompt.StartSentence(); prompt.AppendText(text); prompt.EndSentence(); if (Interval > 0) { prompt.AppendBreak(TimeSpan.FromSeconds(Interval)); } return(prompt); }
public void Say() { if (_text == null) { return; } using (var sp = new SpeechSynthesizer()) { var p = new PromptBuilder(); p.StartSentence(); p.StartStyle(new PromptStyle(PromptRate.Slow)); p.AppendBreak(PromptBreak.Small); p.AppendTextWithHint(new string(_text), SayAs.SpellOut); p.EndStyle(); p.EndSentence(); sp.Speak(p); p.ClearContent(); } }
/// <summary> ///Starts speech connector and starts speaking the prompt message asynchronously. /// </summary> private void StartSpeakAsync() { //start Speech synthesizer if (AudioVideoCall.Flow.SpeechSynthesisConnector != null) { AudioVideoCall.Flow.SpeechSynthesisConnector.DetachFlow(); } m_speechSynthesisConnector.AttachFlow(AudioVideoCall.Flow); m_speechSynthesizer.SetOutputToAudioStream(m_speechSynthesisConnector, m_audioformat); m_speechSynthesizer.SpeakCompleted += new EventHandler <SpeakCompletedEventArgs>(SpeechSynthesizer_SpeakCompleted); m_speechSynthesisConnector.Start(); //If prompt is not set then speak Ssml pause. if (m_pbMainPrompt == null) { m_pbMainPrompt = new PromptBuilder(); m_pbMainPrompt.AppendBreak(); } m_speechSynthesizer.SpeakAsync(m_pbMainPrompt); }
public void SpeakAsync(String text) { if (String.IsNullOrWhiteSpace(text)) { PromptBuilder builder = new PromptBuilder(); builder.AppendBreak(TimeSpan.FromSeconds(1)); if (!Settings.Muted) _voice.SpeakAsync(builder); return; } _spokenWords.Push(text); if (!Settings.Muted) _voice.SpeakAsync(text); if (Spoke != null) Spoke(text); }
private void cmdPromptTest_Click(object sender, RoutedEventArgs e) { PromptBuilder prompt = new PromptBuilder(); prompt.AppendText("How are you"); prompt.AppendBreak(TimeSpan.FromSeconds(2)); prompt.AppendText("How ", PromptEmphasis.Reduced); PromptStyle style = new PromptStyle(); style.Rate = PromptRate.ExtraSlow; style.Emphasis = PromptEmphasis.Strong; prompt.StartStyle(style); prompt.AppendText("are "); prompt.EndStyle(); prompt.AppendText("you?"); SpeechSynthesizer synthesizer = new SpeechSynthesizer(); synthesizer.Speak(prompt); }
private void cmdPromptTest_Click(object sender, RoutedEventArgs e) { PromptBuilder prompt = new PromptBuilder(); prompt.AppendText("How are you"); prompt.AppendBreak(TimeSpan.FromSeconds(2)); prompt.AppendText("How ", PromptEmphasis.Reduced); PromptStyle style = new PromptStyle(); style.Rate = PromptRate.ExtraSlow; style.Emphasis = PromptEmphasis.Strong; prompt.StartStyle(style); prompt.AppendText("are "); prompt.EndStyle(); prompt.AppendText("you?"); SpeechSynthesizer synthesizer = new SpeechSynthesizer(); synthesizer.Speak(prompt); }
private void OnPrompt(object sender, RoutedEventArgs e) { var promptBuilder = new PromptBuilder(); promptBuilder.AppendText("How are you"); promptBuilder.AppendBreak(TimeSpan.FromSeconds(2)); promptBuilder.AppendText("How ", PromptEmphasis.Reduced); var style = new PromptStyle { Rate = PromptRate.ExtraSlow, Emphasis = PromptEmphasis.Strong }; promptBuilder.StartStyle(style); promptBuilder.AppendText("are "); promptBuilder.EndStyle(); promptBuilder.AppendText("you?"); var synthesizer = new SpeechSynthesizer(); synthesizer.Speak(promptBuilder); }
void recEngine_SpeachSpeechRecognized(object sender, SpeechRecognizedEventArgs e) { switch (e.Result.Text) { case "say hello": //MessageBox.Show("Hello Denis. How are you?"); break; PromptBuilder promtBuilder = new PromptBuilder(); promtBuilder.StartSentence(); promtBuilder.AppendText("Hello Denis"); promtBuilder.EndSentence(); promtBuilder.AppendBreak(PromptBreak.ExtraSmall); promtBuilder.AppendText("How are you?"); syncSpeechSynthesizer.SpeakAsync("Hello Denis. How are you?"); break; case "print my name": richTextBox1.Text += "\nDenis"; break; case "speak selected text": syncSpeechSynthesizer.SpeakAsync(richTextBox1.SelectedText); break; } }
public void TTS(string text) { PromptBuilder pb = new PromptBuilder(); pb.AppendText("This is a date"); pb.AppendBreak(); pb.AppendTextWithHint("31-12-2007", SayAs.DayMonthYear); //PromptBuilder(pb); }
private void LISTBOX_XMLpieces_SelectedIndexChanged( object sender, EventArgs e ) { // When the Listbox's selected excerpt changes, we must prepare to edit another excerpt. if( LISTBOX_ShowExcerpts.SelectedIndex > -1 ) { EditXmlExcerpt = LISTBOX_ShowExcerpts.SelectedIndex; } else { // Do not do anything if there is nothing selected (ie SelectedIndex = -1) return; } // The Textbox receives only the MathML excerpt, without wrapper TEXTBOX_MathExpression.Text = RetrieveExcerptFromListbox( LISTBOX_ShowExcerpts.Items[ EditXmlExcerpt ].ToString() ); // The label to the left of the Textbox receives the ID and the Wrapper LABEL_Wrapper.Text = TagifyID( EditXmlExcerpt ) + " " + GetExcerptDescription( xmlPiece[ EditXmlExcerpt ], EditXmlExcerpt ); // Tell the user that a different excerpt has been selected. if( MENU_Options_VoicePrompting.Checked ) { string s = LISTBOX_ShowExcerpts.SelectedItem.ToString(); string excerpt = RetrieveExcerptFromListbox( s ); int excerptNum = Convert.ToInt32( s.Substring( 1, 3 ) ); PromptBuilder p = new PromptBuilder(); p.AppendText( "Line " + excerptNum.ToString() + " selected. " ); p.AppendBreak( new TimeSpan( 0, 0, 0, 0, 100 ) ); StopSpeech(); Speaker.SpeakAsync( p ); PromptBuilder p2 = new PromptBuilder(); p2 = ReadText( excerptNum, false ); Speaker.SpeakAsync( p2 ); } //LISTBOX_XMLpieces_Select(sender, e); }
/// <summary> /// If superscripts are read as powers, this function is used to "read" an exponent. /// </summary> /// <param name="node">The node that represents the exponent of a power (2nd "mrow" argument of "msup" MathML element)</param> /// <returns>Could be "squared", "cubed", "to the n power", or "exponent ... end exponent"</returns> private PromptBuilder ReadExponent( System.Xml.XmlNode node ) { PromptBuilder p = new PromptBuilder(); TimeSpan shortPause = new TimeSpan( 0, 0, 0, 0, 50 ); if( ( node.ChildNodes.Count == 1 ) && ( node.ChildNodes[ 0 ].Name == "mn" ) ) { if( node.ChildNodes[ 0 ].InnerText == "2" ) { // Squared p.AppendText( " squared " ); } else if( node.ChildNodes[ 0 ].InnerText == "3" ) { // Cubed p.AppendText( " cubed " ); } else if( node.ChildNodes[ 0 ].InnerText.Contains( '.' ) ) { // to the x power p.AppendText( " to the " ); p.AppendPromptBuilder( ReadNode( node ) ); p.AppendText( " power " ); } else { // to the n-th power string wordToRead = AddNumericalSuffix( node.ChildNodes[ 0 ].InnerText ); p.AppendText( " to the " ); p.AppendText( wordToRead ); p.AppendText( " power " ); } } else if( TestForSimpleExpression( node ) ) { // Variable exponent... to the x power p.AppendText( " to the " ); p.AppendPromptBuilder( ReadNode( node ) ); p.AppendText( " power " ); } else { // Complex exponent p.AppendText( " exponent " ); p.AppendPromptBuilder( ReadNode( node ) ); p.AppendText( " end exponent " ); } p.AppendBreak( shortPause ); return p; }
/// <summary> /// This function reads all text from within an interior node of the MathML construct. /// </summary> /// <param name="node">The node to recursively process ("0" would read the entire formula)</param> /// <returns>A PromptBuilder representing a spoken rendering of the specified MathML node</returns> private PromptBuilder ReadNode( System.Xml.XmlNode node ) { // This function reads all text from within an interior node of the MathML construct. It // is designed to recursively iterate on all non-trivial MathML elements. In other words, // it reads all <mo>, <mi>, <mn>, <mtext>, and raw text within the node, but recursively // iterates on all children of this node that are not any of the named tags (like <mroot>, // <mfrac>, <msubsup>, etc.) TimeSpan shortPause = new TimeSpan( 0, 0, 0, 0, 50 ); TimeSpan longPause = new TimeSpan( 0, 0, 0, 0, 250 ); PromptBuilder p = new PromptBuilder(); p.AppendText( " " ); // Return an empty PromptBuilder if the node is empty if( node == null ) return p; // These elements need to be parsed //if (node.Name == "mrow") p.AppendPromptBuilder(ReadNode(node, mo, mi)); if( node.Name == "mfrac" ) { // Fraction p.AppendBreak( shortPause ); p.AppendText( " Start fraction " ); p.AppendPromptBuilder( ReadNode( node.ChildNodes.Item( 0 ) ) ); p.AppendBreak( shortPause ); p.AppendText( " over " ); p.AppendPromptBuilder( ReadNode( node.ChildNodes.Item( 1 ) ) ); p.AppendBreak( shortPause ); p.AppendText( " End fraction " ); p.AppendBreak( longPause ); return p; } if( node.Name == "msqrt" ) { // Square Root p.AppendBreak( shortPause ); p.AppendText( " The square root of " ); p.AppendPromptBuilder( ReadNode( node.ChildNodes.Item( 0 ) ) ); p.AppendBreak( shortPause ); p.AppendText( " End Square root " ); p.AppendBreak( longPause ); return p; } if( node.Name == "mroot" ) { // Generic Root PromptBuilder rootValue = new PromptBuilder(); p.AppendBreak( shortPause ); p.AppendText( " Thee " ); // Read Radical may stylize the radical (square, cube, first, twelfth, etc.) rootValue = ReadRadical( node.ChildNodes.Item( 1 ) ); p.AppendPromptBuilder( rootValue ); p.AppendBreak( shortPause ); p.AppendText( " Root of " ); p.AppendPromptBuilder( ReadNode( node.ChildNodes.Item( 0 ) ) ); p.AppendBreak( shortPause ); p.AppendText( " End root " ); p.AppendBreak( longPause ); return p; } if( node.Name == "msub" ) { // Subscript p.AppendBreak( shortPause ); p.AppendText( " Subscripted text " ); p.AppendPromptBuilder( ReadNode( node.ChildNodes.Item( 0 ) ) ); p.AppendBreak( shortPause ); p.AppendText( " Subscript " ); p.AppendPromptBuilder( ReadNode( node.ChildNodes.Item( 1 ) ) ); p.AppendBreak( shortPause ); p.AppendText( " End subscript " ); p.AppendBreak( longPause ); return p; } if( node.Name == "msup" ) { // Superscript if( MENU_Options_ReadAsPower.Checked ) { // Read as a power bool isBaseSimple = TestForSimpleExpression( node.ChildNodes.Item( 0 ) ); if( isBaseSimple ) { // Read naturally if the base is simple p.AppendBreak( shortPause ); p.AppendPromptBuilder( ReadNode( node.ChildNodes.Item( 0 ) ) ); p.AppendPromptBuilder( ReadExponent( node.ChildNodes.Item( 1 ) ) ); } else { // Otherwise, read more formally p.AppendBreak( shortPause ); p.AppendText( " Power Base" ); p.AppendPromptBuilder( ReadNode( node.ChildNodes.Item( 0 ) ) ); p.AppendBreak( shortPause ); p.AppendPromptBuilder( ReadExponent( node.ChildNodes.Item( 1 ) ) ); p.AppendText( " End power " ); p.AppendBreak( longPause ); } } else { // Read very formally as a superscript p.AppendBreak( shortPause ); p.AppendText( " Superscripted text " ); p.AppendPromptBuilder( ReadNode( node.ChildNodes.Item( 0 ) ) ); p.AppendBreak( shortPause ); p.AppendText( " Superscript " ); p.AppendPromptBuilder( ReadNode( node.ChildNodes.Item( 1 ) ) ); p.AppendBreak( shortPause ); p.AppendText( " End superscript " ); p.AppendBreak( longPause ); } return p; } if( node.Name == "msubsup" ) { // Subscript/superscript p.AppendBreak( shortPause ); p.AppendText( " Sub and super scripted text " ); p.AppendPromptBuilder( ReadNode( node.ChildNodes.Item( 0 ) ) ); p.AppendBreak( shortPause ); p.AppendText( " Subscript " ); p.AppendPromptBuilder( ReadNode( node.ChildNodes.Item( 1 ) ) ); p.AppendBreak( shortPause ); p.AppendText( " Superscript " ); p.AppendPromptBuilder( ReadNode( node.ChildNodes.Item( 2 ) ) ); p.AppendBreak( shortPause ); p.AppendText( " End superscript " ); p.AppendBreak( longPause ); return p; } if( node.Name == "mover" ) { // Over p.AppendBreak( shortPause ); p.AppendText( " Start over text " ); p.AppendPromptBuilder( ReadNode( node.ChildNodes.Item( 1 ) ) ); p.AppendBreak( shortPause ); p.AppendText( " over " ); p.AppendPromptBuilder( ReadNode( node.ChildNodes.Item( 0 ) ) ); p.AppendBreak( shortPause ); p.AppendText( " End over text " ); p.AppendBreak( longPause ); return p; } if( node.Name == "munder" ) { // Under p.AppendBreak( shortPause ); p.AppendText( " Start under text " ); p.AppendPromptBuilder( ReadNode( node.ChildNodes.Item( 1 ) ) ); p.AppendBreak( shortPause ); p.AppendText( " under " ); p.AppendPromptBuilder( ReadNode( node.ChildNodes.Item( 0 ) ) ); p.AppendBreak( shortPause ); p.AppendText( " End under text " ); p.AppendBreak( longPause ); return p; } if( node.Name == "munderover" ) { // Under/Over p.AppendBreak( shortPause ); p.AppendText( " Start over/under text " ); p.AppendPromptBuilder( ReadNode( node.ChildNodes.Item( 1 ) ) ); p.AppendBreak( shortPause ); p.AppendText( " over " ); p.AppendPromptBuilder( ReadNode( node.ChildNodes.Item( 2 ) ) ); p.AppendBreak( shortPause ); p.AppendText( " under " ); p.AppendPromptBuilder( ReadNode( node.ChildNodes.Item( 0 ) ) ); p.AppendBreak( shortPause ); p.AppendText( " End over/under text " ); p.AppendBreak( longPause ); return p; } if( node.Name == "mfenced" ) { // Fenced (a set of numbers/variables) if( ( node.PreviousSibling != null ) && ( node.PreviousSibling.Name == "mi" ) ) { // Read as a Function parameter set p.AppendBreak( shortPause ); p.AppendText( " of " ); int counter = 1; foreach( XmlNode n in node.ChildNodes ) { p.AppendPromptBuilder( ReadNode( n ) ); if ( counter++ < node.ChildNodes.Count ) p.AppendText( " and " ); //counter++; p.AppendBreak( shortPause ); } if ( node.ChildNodes.Count > 1 ) p.AppendText( " end parameters " ); p.AppendBreak( longPause ); return p; } else { // Read as an ordinary set p.AppendBreak( shortPause ); p.AppendText( " Open set " ); foreach( XmlNode n in node.ChildNodes ) { p.AppendPromptBuilder( ReadNode( n ) ); p.AppendBreak( longPause - shortPause ); } p.AppendText( " Close set " ); p.AppendBreak( longPause ); return p; } } for( int i = 0; i < node.ChildNodes.Count; i++ ) { System.Xml.XmlNode readNode = node.ChildNodes.Item( i ); if( readNode.Name == "#text" ) { p.AppendText( " " + readNode.InnerText + " " ); // This is straight text p.AppendBreak( shortPause ); } if( readNode.Name == "mn" ) p.AppendText( readNode.InnerText + " " ); // This is a number if( readNode.Name == "mo" ) // This is an operator { // Must search master list for its pronunciation for( int j = 0; j < ( MasterToken._moCount ); j++ ) { Token t = MasterToken._mo[ j ]; if( readNode.InnerText == t._symbol ) { // Barf. Need this hack because Invisible Plus does not render correctly... so it looks like Invisible Times. if( t._symbol == "" ) { // If t.symbol is Invisible Times, check if it should be Invisible Plus if( ( readNode.PreviousSibling.Name == "mn" ) & ( readNode.NextSibling.Name == "mfrac" ) ) { // Ah. In this case, find how to say Invisible Plus for( int k = 0; k < MasterToken._moCount; k++ ) if( MasterToken._mo[ k ]._symbol == "" ) p.AppendText( MasterToken._mo[ k ]._speech + " " ); } else p.AppendText( t._speech + " " ); } else p.AppendText( t._speech + " " ); } } // Check the mo group } if( readNode.Name == "mi" ) // This is a letter or symbol { bool speakMi = true; // Check for symbols first... if not found in the master list, the token will be pronouced as a letter for( int j = 0; j < ( MasterToken._miCount ); j++ ) { Token t = MasterToken._mi[ j ]; if( readNode.InnerText == t._symbol ) { p.AppendText( t._speech + " " ); speakMi = false; break; } } // Check the mi group if( speakMi ) p.AppendTextWithHint( Convert.ToString( readNode.InnerText ) + " ", SayAs.SpellOut ); } // Basically, if this node is not named one of these things, then it should be // read now. This means <mrow> and <mtext> elements. if( ( readNode.Name != "mi" ) && ( readNode.Name != "mo" ) && ( readNode.Name != "mn" ) && ( readNode.Name != "#text" ) ) p.AppendPromptBuilder( ReadNode( readNode ) ); } // Make sure that a trailing space is appended to the end of an <mrow> element if( node.Name == "mrow" ) p.AppendText( " " ); return p; }
/// <summary> /// This function reads an excerpt of MathML from "LISTBOX_ShowExcerpts". /// </summary> /// <param name="excerpt">The ID of the MathML excerpt to read</param> /// <param name="goDeeper">True to read ID tags recursively, false to read ID tags woodenly</param> /// <returns>A PromptBuilder representing a spoken rendering of the specified math excerpt</returns> private PromptBuilder ReadText( int excerpt, bool goDeeper ) { PromptBuilder p = new PromptBuilder(); string excerptAndPrompt = LISTBOX_ShowExcerpts.Items[ excerpt ].ToString(); string excerptTag = GetXmlWrapper( excerptAndPrompt ); //excerptTag = excerptTag.Substring( 6 ); string tx = RetrieveExcerptFromListbox( excerptAndPrompt ); Char[] c = tx.ToCharArray(); bool speakMiChar = true; // These checks will determine if extra words are needed to delineate that we are in a // special mathML tag bool spokeTag = false; string textExcerpt = ""; for( int j = 1; j < ( MasterToken._elemCount ); j++ ) { Token t = MasterToken._mathMLelement[ j ]; if( excerptTag == t._symbol ) { p.AppendText( t._speech ); spokeTag = true; } if( t._symbol == "mtext" ) textExcerpt = MasterToken._elemEnglish[ j ][ 0 ]; } // Check the mo group if( !spokeTag ) p.AppendText( excerptTag ); p.AppendBreak( new TimeSpan( 0, 0, 0, 0, 250 ) ); // Check for Text tag; should be read literally if( ( excerptTag == "mtext" ) | ( excerptTag == textExcerpt ) ) { p.AppendText( tx ); return p; } // This function will convert the text in the Textbox to speech for( int i = 0; i < ( tx.Length ); i++ ) { // Letters convert to an <m:mi> tag if( Char.IsLetter( c[ i ] ) & ( Convert.ToInt32( c[ i ] ) < 256 ) ) { // Greek letters are considered letters! // First, check if this letter begins a function name! speakMiChar = true; for( int j = 0; j < ( MasterToken._miCount ); j++ ) { Token t = MasterToken._mi[ j ] as Token; string sym = t._symbol; if( sym.Length <= ( tx.Length - i ) ) { if( tx.Substring( i, sym.Length ) == sym ) { p.AppendText( t._speech + " " ); i = i + sym.Length - 1; speakMiChar = false; break; } } } // Check the mi group if( speakMiChar ) p.AppendTextWithHint( Convert.ToString( c[ i ] ) + " ", SayAs.SpellOut ); } // Letter check if( Char.IsDigit( c[ i ] ) || c[ i ] == '.' ) { int startNum = i; int finNum = i; for( finNum = i; finNum < tx.Length; finNum++ ) if( !Char.IsDigit( c[ finNum ] ) && c[ finNum ] != '.' && c[ finNum ] != ',' ) break; string sayNum = ""; for( int k = i; k < finNum; k++ ) sayNum += c[ k ]; sayNum = Convert.ToDouble( sayNum ).ToString(); p.AppendTextWithHint( sayNum + " ", SayAs.Text ); i = finNum - 1; } // check for Numbers if( i < tx.Length ) { // Otherwise, must find the speech text in the Master Token List XML int j = 0; for( j = 0; j < ( MasterToken._moCount ); j++ ) { Token t = MasterToken._mo[ j ] as Token; Char[] sym = t._symbol.ToCharArray(); if( c[ i ] == sym[ 0 ] ) p.AppendText( t._speech + " " ); } // Check the mo group if( speakMiChar ) { for( j = 0; j < ( MasterToken._miCount ); j++ ) { Token t = MasterToken._mi[ j ] as Token; string sym = t._symbol; if( ( i + sym.Length ) < tx.Length ) if( tx.Substring( i, sym.Length ) == sym ) p.AppendText( t._speech + " " ); } // Check the mi group } // ⊰- Finally, we need to test for Excerpt tags! if( c[ i ] == '⊰' ) { int thisID = Convert.ToInt32( tx.Substring( i + 1, 3 ) ); if( goDeeper == true ) { PromptBuilder appendThis = new PromptBuilder(); appendThis = ReadText( thisID, true ); p.AppendPromptBuilder( appendThis ); } else { p.AppendText( "Line " ); p.AppendText( thisID.ToString() + " " ); } i = i + 4; } // Check for excerpt tags // -⊱ p.AppendBreak( new TimeSpan( 0, 0, 0, 0, 125 ) ); } } return p; }
/// <summary> /// Handler for MSG_QUERY /// </summary> /// <param name="message">The message received</param> protected async void MsgQuery(dynamic message) { var data = message["data"]; MycroftSpeaker speaker = speakers[data["targetSpeaker"]]; if (speaker.Status != "up") { await QueryFail(message["id"], "Target speaker is " + speaker.Status); } else { var text = data["text"]; PromptBuilder prompt = new PromptBuilder(new System.Globalization.CultureInfo("en-GB")); prompt.StartVoice(VoiceGender.Female, VoiceAge.Adult, 0); foreach (var phrase in text) { prompt.AppendText(phrase["phrase"]); prompt.AppendBreak(new TimeSpan((int)(phrase["delay"] * 10000000))); } prompt.EndVoice(); try { prompt.AppendAudio("lutz.wav"); } catch { } Thread t = new Thread(Listen); t.Start(new { speaker = speaker, prompt = prompt }); await Query("audioOutput", "stream_tts", new { ip = ipAddress, port = speaker.Port }, new string[] { speaker.InstanceId }); } }