Пример #1
0
        static void Main(string[] args)
        {
#if DEBUG
            logfile.CreateLog();             // NOTE: The logfile works in debug-builds only.
            // To write a line to the logfile:
            // logfile.Log("what you want to know string");
            //
            // The logfile ought appear in the directory with the executable.
#endif

            if (args.Length == 2)             // TODO: test that.
            {
                var kittencuddles = new FxeGeneratorF(args[0], args[1]);
                Application.Run();
            }
            else
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new FxeGeneratorF());
            }
        }
Пример #2
0
        /// <summary>
        /// cTor.
        /// </summary>
        /// <param name="f">parent</param>
        /// <param name="dt">datatable</param>
        internal EditorPhonF(FxeGeneratorF f, DataTable dt)
        {
            InitializeComponent();
            _f  = f;
            _dt = dt;


            foreach (DataColumn dc in _dt.Columns)             // datatable editable
            {
                dc.ReadOnly = false;
            }

            grid.Table = _dt;             // TODO: grid initialization to 'grid.Table.set' ->

            int i = 0;

            for (; i != _dt.Rows.Count; ++i)
            {
                grid.Rows.Add();
                grid.Rows[i].HeaderCell.Value = _dt.Rows[i][0].ToString();                 // pos
                grid.Rows[i].Cells[0].Value   = _dt.Rows[i][1].ToString();                 // phon
                grid.Rows[i].Cells[1].Value   = _dt.Rows[i][2].ToString();                 // start
                grid.Rows[i].Cells[2].Value   = _dt.Rows[i][3].ToString();                 // stop
            }

            int w = grid.RowHeadersWidth
                    + grid.Columns[0].Width
                    + grid.Columns[1].Width
                    + grid.Columns[2].Width;
            int h = grid.ColumnHeadersHeight
                    + (grid.RowTemplate.Height + 1) * (i + 2)
                    + pa_bot.Height;

            if (h > START_H)
            {
                h = START_H;
            }

            ClientSize  = new Size(w, h);
            MaximumSize = new Size(w, 1000);
            MinimumSize = new Size(w, 0);

            Screen screen = Screen.FromControl(this);
            int    height = screen.WorkingArea.Height;

            int bordersVert = Height - h;

            int x, y;

            if (_x != -1)
            {
                x = _x;

                if (_y + h + bordersVert > height)
                {
                    y = height - h - bordersVert;
                }
                else
                {
                    y = _y;
                }
            }
            else
            {
                x = _f.Left + 20;

                if (_f.Top + 20 + h + bordersVert > height)
                {
                    y = height - h - bordersVert;
                }
                else
                {
                    y = _f.Top + 20;
                }
            }
            Location = new Point(x, y);
        }
Пример #3
0
        /// <summary>
        /// cTor.
        /// </summary>
        /// <param name="pfe">blank string if '!isConsole'</param>
        /// <param name="headtype">blank string if '!isConsole'</param>
        internal FxeGeneratorF(string pfe = "", string headtype = "")
        {
#if DEBUG
//			LogSpeechRecognitionEngines();
            logfile.Log("FxeGeneratorF() cTor pfe= " + pfe + " headtype= " + headtype);
#endif

            That = this;

            FxeData.LoadTrigrams();

            bool fatality = false;

            if (pfe == String.Empty)             // is GUI interface ->
            {
#if DEBUG
                logfile.Log(". is GUI");
#endif
                InitializeComponent();

                co_headtype.SelectedIndex = 0;

                la_def_word_pct.Text             =
                    la_def_phon_pct.Text         =
                        la_enh_word_pct.Text     =
                            la_enh_phon_pct.Text = String.Empty;

                tb_text.Text = String.Empty;

                tb_text.BackColor         =
                    tb_expected.BackColor = Color.AntiqueWhite;

                tb_def_words.BackColor             =
                    tb_def_phons.BackColor         =
                        tb_enh_words.BackColor     =
                            tb_enh_phons.BackColor = Color.GhostWhite;


// PHONEMES data/grid ->
                DataColumn dc;
                dc          = new DataColumn(HEAD_PHONS_0, typeof(string));        // pos
                dc.ReadOnly = true;
                _dt1.Columns.Add(dc);

                dc          = new DataColumn(HEAD_PHONS_1, typeof(string));        // phon
                dc.ReadOnly = true;
                _dt1.Columns.Add(dc);

                dc          = new DataColumn(HEAD_PHONS_2, typeof(string));        // start
                dc.ReadOnly = true;
                _dt1.Columns.Add(dc);

                dc          = new DataColumn(HEAD_PHONS_3, typeof(string));        // stop
                dc.ReadOnly = true;
                _dt1.Columns.Add(dc);

                dc          = new DataColumn(HEAD_PHONS_4, typeof(string));        // vis
                dc.ReadOnly = true;
                _dt1.Columns.Add(dc);

                dc          = new DataColumn(HEAD_PHONS_5, typeof(string));        // truth
                dc.ReadOnly = true;
                _dt1.Columns.Add(dc);

                dc          = new DataColumn(HEAD_PHONS_6, typeof(string));        // level
                dc.ReadOnly = true;
                _dt1.Columns.Add(dc);

                grid_phons.DataSource       = _dt1;
                grid_phons.Columns[0].Width = 50;                 // 50 "pos"
                grid_phons.Columns[1].Width = 76;                 // 76 "phoneme"
                grid_phons.Columns[2].Width = 86;                 // 86 "start"
                grid_phons.Columns[3].Width = 86;                 // 86 "stop"
                grid_phons.Columns[4].Width = 67;                 // 67 "viseme"
                grid_phons.Columns[5].Width = 57;                 // 57 "truth"
                grid_phons.Columns[6].Width = 61;                 // 56 "level"

                for (int i = 0; i != grid_phons.Columns.Count; ++i)
                {
                    grid_phons.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
                }


// Data Blocks data/grid ->
                dc          = new DataColumn(HEAD_BLOCKS_0, typeof(string));
                dc.ReadOnly = true;
                _dt2.Columns.Add(dc);

                dc          = new DataColumn(HEAD_BLOCKS_1, typeof(float));
                dc.ReadOnly = true;
                _dt2.Columns.Add(dc);

                dc          = new DataColumn(HEAD_BLOCKS_2, typeof(float));
                dc.ReadOnly = true;
                _dt2.Columns.Add(dc);

                grid_blocs.DataSource = _dt2;
//				grid_blocs.Columns[0].Width =  80; //  68 "viseme"
//				grid_blocs.Columns[1].Width =  97; //  87 "frame stop"
//				grid_blocs.Columns[2].Width = 110; // 100 "morph weight"
                grid_blocs.Columns[0].Width = 140;                 //  68 "viseme"
                grid_blocs.Columns[1].Width = 67;                  //     "stop"
                grid_blocs.Columns[2].Width = 80;                  //     "weight"

//				for (int i = 0; i != grid_blocs.Columns.Count; ++i)
//					grid_blocs.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
                grid_blocs.Columns[0].SortMode     = DataGridViewColumnSortMode.NotSortable;
                grid_blocs.Columns[2].SortMode     = DataGridViewColumnSortMode.NotSortable;
                grid_blocs.ColumnHeaderMouseClick += dgblocs_ColumnHeaderMouseClick;

                grid_phons.RowHeadersVisible     =
                    grid_blocs.RowHeadersVisible = false;

                printversion();


                // instantiate/initialize SAPI
                _sapi = new SapiLipsync();
                _sapi.TtsStreamEnded += OnTtsStreamEnded;
                _sapi.SrStreamEnded  += OnSrStreamEnded;

                // this will set '_sapi._recognizer'
                // this will set '_sapi._phoneConverter.LanguageId'
                // and the Titletext
                if (!SpeechRecognizerLister.AddSpeechRecognizers(co_recognizers))
                {
                    string info = "FXE LipSyncer requires a SAPI 5.4 compliant" + Environment.NewLine
                                  + "Microsoft Speech Recognizer" + Environment.NewLine
                                  + "as displayed in Windoz ControlPanel|SpeechRecognition." + Environment.NewLine
                                  + Environment.NewLine
                                  + "none was found ...";
                    using (var d = new InfoDialog("FATAL Error", info))
                    {
                        d.ShowDialog(this);
                    }
                    fatality = true;
                }
            }
            else if (headtype != String.Empty && File.Exists(pfe))             // is Console interface ->
            {
#if DEBUG
                logfile.Log(". is Console");
#endif
                // TODO: Fail if a Recognizer is not found.

                // TODO: Ensure that 'head Model/Skeleton type' is a recognized type.
                // Eg. "P_HHM"

                Filelabel = Utility.GetFilelabel(pfe);                 // NOTE: that will be written into the FXE-file output.

                _sapi = new SapiLipsync(_pfe = pfe);
                if (_sapi.Wavefile != String.Empty)
                {
                    isConsole = true;
                    _headtype = headtype;

                    _sapi.SrStreamEnded += OnSrStreamEnded;
                    _sapi.Start(LoadTypedTextFile());
                }
                else
                {
                    fatality = true;
                }
            }
            else             // is Console error ->
            {
                fatality = true;
            }

            if (fatality)
            {
                Environment.Exit(0);
            }
        }