/// <summary> /// Opens the synth-player. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void click_Synth(object sender, EventArgs e) { tb_text.Text = TypedText.SanitizeTypedText(tb_text.Text); bu_synth.Enabled = false; var synth = new VoiceSynthF(this, tb_text.Text); synth.Show(this); }
/// <summary> /// Plays the audio-file. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void click_Play(object sender, EventArgs e) { tb_text.Text = TypedText.SanitizeTypedText(tb_text.Text); using (var fs = new FileStream(_sapi.Wavefile, FileMode.Open, FileAccess.Read, FileShare.Read)) using (var player = new SoundPlayer(fs)) { player.SoundLocation = _sapi.Wavefile; player.Play(); } }
/// <summary> /// Loads a user-prepared file w/ typed-text. /// </summary> /// <returns></returns> string LoadTypedTextFile() { string file = _pfe.Substring(0, _pfe.Length - 3) + EXT_TXT; if (File.Exists(file)) { using (var sr = new StreamReader(file)) { return(TypedText.SanitizeTypedText(sr.ReadToEnd())); } } return(String.Empty); }
/// <summary> /// Generates data for an FXE file. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void click_Generate(object sender, EventArgs e) { #if DEBUG logfile.Log(); logfile.Log(); logfile.Log("click_Generate() ==============================================================="); #endif Cursor = Cursors.WaitCursor; // shall return to Default cursor either OnSrStreamEnded() or an InfoDialog error. tb_text.Text = TypedText.SanitizeTypedText(tb_text.Text); Clear(); _sapi.Start(tb_text.Text); }
/// <summary> /// Sets the typed-text when Ok is clicked in the VoiceSynthesizer /// dialog. /// </summary> /// <param name="text"></param> internal void SetText(string text) { tb_text.Text = TypedText.SanitizeTypedText(text); }
void CalculateRatios_word() { #if DEBUG logfile.Log(); logfile.Log("CalculateRatios_word()"); #endif // give the default pass an honest chance to match its words to a typed-text string text = TypedText.StripTypedText(_text); #if DEBUG logfile.Log(". _ars_def.Count= " + _ars_def.Count); logfile.Log(". text(stripped)= " + text); #endif var words = new List <string>(text.Split(new [] { ' ' }, StringSplitOptions.RemoveEmptyEntries)); if (words.Count != 0) { var words_def = new List <string>(); foreach (var ar in _ars_def) { if (ar.Orthography != String.Empty) { #if DEBUG logfile.Log(". . add " + ar.Orthography); #endif words_def.Add(ar.Orthography.ToLower()); } } int count_def_over = Math.Max(0, words_def.Count - words.Count); int count_def = 0; foreach (string word in words) { if (words_def.Contains(word)) { words_def.Remove(word); ++count_def; } } #if DEBUG logfile.Log(". (" + count_def + " - " + count_def_over + ") / " + words.Count); #endif RatioWords_def = Math.Max(0.0, (double)(count_def - count_def_over) / words.Count); } #if DEBUG logfile.Log(". _ars_enh.Count= " + _ars_enh.Count); logfile.Log(". _text= " + _text); #endif words = new List <string>(_text.Split(new [] { ' ' }, StringSplitOptions.RemoveEmptyEntries)); if (words.Count != 0) { var words_enh = new List <string>(); foreach (var ar in _ars_enh) { if (ar.Orthography != String.Empty) { #if DEBUG logfile.Log(". . add " + ar.Orthography); #endif words_enh.Add(ar.Orthography); } } int count_enh_over = Math.Max(0, words_enh.Count - words.Count); int count_enh = 0; foreach (string word in words) { if (words_enh.Contains(word)) { words_enh.Remove(word); ++count_enh; } } #if DEBUG logfile.Log(". (" + count_enh + " - " + count_enh_over + ") / " + words.Count); #endif RatioWords_enh = Math.Max(0.0, (double)(count_enh - count_enh_over) / words.Count); } }