/// <summary> /// Writes an FXE file to a user-chosen filepath. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void click_CreateFxe(object sender, EventArgs e) { #if DEBUG logfile.Log(); logfile.Log("click_CreateFxe()"); #endif using (var sfd = new SaveFileDialog()) { // sfd.Title = "Save as ..."; sfd.Filter = "FXE files (*.fxe)|*.fxe|All files (*.*)|*.*"; if (Directory.Exists(_dirCreate)) { sfd.InitialDirectory = _dirCreate; } else { string dir = Path.GetDirectoryName(_pfe); if (Directory.Exists(dir)) { sfd.InitialDirectory = dir; } } // else let .NET handle it. sfd.FileName = Utility.GetFilelabel(_pfe) + "." + EXT_FXE; if (sfd.ShowDialog(this) == DialogResult.OK) { _dirCreate = Path.GetDirectoryName(sfd.FileName); FxeWriter.WriteFile(sfd.FileName, co_headtype.Text, _fxedata); } } }
/// <summary> /// This is the biggie. Generates and prints data after the /// SpeechRecognition stream of an audio-file finishes. /// </summary> /// <param name="ars_def"></param> /// <param name="ars_enh"></param> void OnSrStreamEnded(List <OrthographicResult> ars_def, List <OrthographicResult> ars_enh) { #if DEBUG logfile.Log(); logfile.Log("OnSrStreamEnded() ars_def.Count= " + ars_def.Count + " ars_enh.Count= " + ars_enh.Count); #endif _ars_def = ars_def; _ars_enh = ars_enh; if (!isConsole) { PrintResults(_ars_def, tb_def_words, tb_def_phons); if (tb_text.Text != String.Empty) { PrintResults(_ars_enh, tb_enh_words, tb_enh_phons); la_def_word_pct.Text = _sapi.RatioWords_def.ToString("P1"); la_enh_word_pct.Text = _sapi.RatioWords_enh.ToString("P1"); } else { la_def_word_pct.Text = _sapi.Confidence_def.ToString("P1"); } if (_sapi.Expected.Count != 0) { la_def_phon_pct.Text = _sapi.RatioPhons_def.ToString("P1"); la_enh_phon_pct.Text = _sapi.RatioPhons_enh.ToString("P1"); rb_def.Visible = rb_enh.Visible = true; } ColorPercents(tb_text.Text == String.Empty); bu_createfxe.Enabled = co_headtype.Enabled = true; } FxeData.GenerateData(_ars_def, _fxedata_def); FxeData.GenerateData(_ars_enh, _fxedata_enh); #if DEBUG logfile.Log(". _sapi.RatioPhons_def= " + _sapi.RatioPhons_def); logfile.Log(". _sapi.RatioPhons_enh= " + _sapi.RatioPhons_enh); #endif if (tb_text.Text == String.Empty || _sapi.RatioPhons_def > _sapi.RatioPhons_enh) { #if DEBUG logfile.Log(". select DEFault"); #endif if (!isConsole) { #if DEBUG logfile.Log(". . rb_def"); #endif rb_def.Checked = true; // fire rb_CheckChanged } else { _fxedata = _fxedata_def; } } else { #if DEBUG logfile.Log(". select ENHanced"); #endif if (!isConsole) { #if DEBUG logfile.Log(". . rb_enh"); #endif rb_enh.Checked = true; // fire rb_CheckChanged } else { _fxedata = _fxedata_enh; } } if (!isConsole) { bu_edit.Enabled = bu_save.Enabled = (_dt1 != null && _dt1.Rows.Count != 0); bu_load.Enabled = true; Cursor = Cursors.Default; } else { string pfe = _pfe.Substring(0, _pfe.Length - 3).ToLower() + FxeGeneratorF.EXT_FXE; FxeWriter.WriteFile(pfe, _headtype, _fxedata); Application.Exit(); } }