Exemple #1
0
        private void spv_SpeakProgress(object sender, System.Speech.Synthesis.SpeakProgressEventArgs e)
        {
            TimeSpan df = e.AudioPosition;

            //double cPT = double.Parse(Math.Round(df.TotalSeconds).ToString() + "." +  Math.Round(df.TotalMilliseconds).ToString());
            double cPT = df.TotalSeconds;
            double xPT = (cPT * 30) / 100;

            xPT = xPT - (xPT * 13 / 136);
            cPT = (cPT - xPT);

            //string aTime = df.Seconds.ToString() + "." + df.Milliseconds.ToString() + "s";
            //string caTime = df.Seconds.ToString() + "." + (df.Milliseconds - 2).ToString() + "s";

            string aTime  = String.Format("{0:0.########}", cPT) + "s";
            string caTime = String.Format("{0:0.########}", cPT) + "s";

            double lTime = cPT + xPT;

            last_time = String.Format("{0:0.########}", lTime) + "s";


            string spTxt = "";

            #region pro text
            int sPoint = e.CharacterPosition;

            if (curFullTxt.IndexOf(" ", sPoint) != -1)
            {
                int ePoint = curFullTxt.IndexOf(" ", sPoint);
                try
                {
                    if (curFullTxt.Substring(sPoint - 1, 1) == "\"")
                    {
                        sPoint = sPoint - 1;
                    }
                }
                catch { }
                spTxt = curFullTxt.Substring(sPoint, ePoint - sPoint);
            }
            else
            {
                spTxt = e.Text;
            }
            #endregion

            spTxt = spTxt.Replace("<", "&lt;");
            spTxt = spTxt.Replace(">", "&gt;");
            spTxt = spTxt.Replace("&", "&amp;");

            Regex           wFnx      = new Regex("\\s*(.+?)\\s", RegexOptions.IgnoreCase);
            string          mtchTxt   = "";
            MatchCollection mtchPoint = null;
            int             mInt      = 0;


            if (wFnx.Match(htLineTxt, spanPoint).Success)
            {
                mtchPoint = wFnx.Matches(htLineTxt, spanPoint);
                try
                {
                    if (mtchPoint[0].Groups[1].Value == spTxt)
                    {
                        mtchTxt = mtchPoint[0].Groups[1].Value;
                        mInt    = 0;
                    }
                    else if (mtchPoint[1].Groups[1].Value == spTxt)
                    {
                        mtchTxt = mtchPoint[1].Groups[1].Value;
                        mInt    = 1;
                    }
                    else if (mtchPoint[2].Groups[1].Value == spTxt)
                    {
                        mtchTxt = mtchPoint[2].Groups[1].Value;
                        mInt    = 2;
                    }
                    else if (mtchPoint[3].Groups[1].Value == spTxt)
                    {
                        mtchTxt = mtchPoint[3].Groups[1].Value;
                        mInt    = 3;
                    }
                    else if (mtchPoint[4].Groups[1].Value == spTxt)
                    {
                        mtchTxt = mtchPoint[4].Groups[1].Value;
                        mInt    = 4;
                    }
                }
                catch { }
            }

            if (spTxt == mtchTxt)
            {
                int stPoint = mtchPoint[mInt].Groups[1].Index;
                int etPoint = stPoint + spTxt.Length;
                htLineTxt = htLineTxt.Insert(etPoint, "</span>");
                string spanidTxt = "<span id=\"w" + spanID.ToString() + "\">";
                htLineTxt = htLineTxt.Insert(stPoint, spanidTxt);


                spanPoint = etPoint + 7 + spanidTxt.Length;
            }

            smilTxt = smilTxt.Replace("[etime/]", caTime);

            string pTxt = "<par id=\"par" + spanID.ToString() + "\">\n";
            pTxt    += "<text src=\"" + curPageHtml + "#w" + spanID.ToString() + "\" />\n";
            pTxt    += "<audio src=\"../audio/" + curaudioFile + "\" clipBegin=\"" + aTime + "\" clipEnd=\"[etime/]\"/>\n";
            pTxt    += "</par>\n";
            smilTxt += pTxt;

            spanID++;

            //probar update
            try
            {
                probar.Value += 1;
            }
            catch { }
        }
 private void Api_SpeakProgress(object sender, System.Speech.Synthesis.SpeakProgressEventArgs e)
 {
     speechViewControl.UpdateSelection(e.CharacterPosition, e.CharacterCount);
 }
        //Post update of progress for System Speech Synthesizer
        static void SynthProgressUpdate(object sender, System.Speech.Synthesis.SpeakProgressEventArgs e)
        {
            int percent = (int)(100.0f * (float)e.CharacterPosition / (float)textLength);

            Console.Write("\r " + fileName + " Progress: {0}%   ", percent);
        }