Пример #1
0
 public void SpeakAsyncCancelAll()
 {
     if (MONO)
     {
         try
         {
             if (_speechlinux != null)
             {
                 _speechlinux.Close();
             }
         }
         catch { }
         _state = SynthesizerState.Ready;
     }
     else
     {
         try
         {
             if (_speechwindows != null)
             {
                 _speechwindows.SpeakAsyncCancelAll();
             }
         }
         catch (System.PlatformNotSupportedException)
         {
             _speechwindows = null;
         }
         catch { }
     }
 }
Пример #2
0
        public void SpeakAsync(string text)
        {
            if (MONO)
            {
                //if (_speechlinux == null)
                {
                    _state       = SynthesizerState.Speaking;
                    _speechlinux = new System.Diagnostics.Process();
                    _speechlinux.StartInfo.RedirectStandardInput = true;
                    _speechlinux.StartInfo.UseShellExecute       = false;
                    _speechlinux.StartInfo.FileName = "festival";
                    _speechlinux.Start();
                    _speechlinux.Exited += new EventHandler(_speechlinux_Exited);

                    log.Info("TTS: start " + _speechlinux.StartTime);
                }

                _state = SynthesizerState.Speaking;
                _speechlinux.StandardInput.WriteLine("(SayText \"" + text + "\")");
                _speechlinux.StandardInput.WriteLine("(quit)");

                _speechlinux.Close();

                _state = SynthesizerState.Ready;
            }
            else
            {
                _speechwindows.SpeakAsync(text);
            }

            log.Info("TTS: say " + text);
        }
Пример #3
0
        public void SpeakAsync(string text)
        {
            if (MONO)
            {
                //if (_speechlinux == null)
                {
                    _state = SynthesizerState.Speaking;
                    _speechlinux = new System.Diagnostics.Process();
                    _speechlinux.StartInfo.RedirectStandardInput = true;
                    _speechlinux.StartInfo.UseShellExecute = false;
                    _speechlinux.StartInfo.FileName = "festival";
                    _speechlinux.Start();
                    _speechlinux.Exited += new EventHandler(_speechlinux_Exited);

                    log.Info("TTS: start " + _speechlinux.StartTime);

                }

                _state = SynthesizerState.Speaking;
                _speechlinux.StandardInput.WriteLine("(SayText \"" + text + "\")");
                _speechlinux.StandardInput.WriteLine("(quit)");

                _speechlinux.Close();

                _state = SynthesizerState.Ready;
            }
            else
            {
                _speechwindows.SpeakAsync(text);
            }

            log.Info("TTS: say " + text);
        }
Пример #4
0
        public void SpeakAsync(string text)
        {
            if (text == null)
            {
                return;
            }

            text = Regex.Replace(text, @"\bPreArm\b", "Pre Arm", RegexOptions.IgnoreCase);
            text = Regex.Replace(text, @"\bdist\b", "distance", RegexOptions.IgnoreCase);
            text = Regex.Replace(text, @"\bNAV\b", "Navigation", RegexOptions.IgnoreCase);
            text = Regex.Replace(text, @"\b([0-9]+)m\b", "$1 meters", RegexOptions.IgnoreCase);
            text = Regex.Replace(text, @"\b([0-9]+)ft\b", "$1 feet", RegexOptions.IgnoreCase);
            text = Regex.Replace(text, @"\b([0-9]+)\bbaud\b", "$1 baudrate", RegexOptions.IgnoreCase);

            if (MONO)
            {
                try
                {
                    //if (_speechlinux == null)
                    {
                        _state       = SynthesizerState.Speaking;
                        _speechlinux = new System.Diagnostics.Process();
                        _speechlinux.StartInfo.RedirectStandardInput = true;
                        _speechlinux.StartInfo.UseShellExecute       = false;
                        _speechlinux.StartInfo.FileName = "festival";
                        _speechlinux.Start();
                        _speechlinux.Exited += new EventHandler(_speechlinux_Exited);

                        log.Info("TTS: start " + _speechlinux.StartTime);
                    }

                    _state = SynthesizerState.Speaking;
                    _speechlinux.StandardInput.WriteLine("(SayText \"" + text + "\")");
                    _speechlinux.StandardInput.WriteLine("(quit)");

                    _speechlinux.Close();
                }
                catch { } // ignore errors

                _state = SynthesizerState.Ready;
            }
            else
            {
                try
                {
                    if (_speechwindows != null)
                    {
                        PromptBuilder pb = new PromptBuilder(CultureInfo.CurrentUICulture);
                        pb.AppendText(text);
                        _speechwindows.SpeakAsync(pb);
                    }
                }
                catch (COMException)
                {
                }
            }

            log.Info("TTS: say " + text);
        }
Пример #5
0
 public void SpeakAsyncCancelAll()
 {
     if (MONO)
     {
         _speechlinux.Close();
         _state = SynthesizerState.Ready;
     }
     else
     {
         _speechwindows.SpeakAsyncCancelAll();
     }
 }
Пример #6
0
        public void SpeakAsync(string text)
        {
            if (text == null)
                return;

            text = Regex.Replace(text, @"\bPreArm\b", "Pre Arm", RegexOptions.IgnoreCase);
            text = Regex.Replace(text, @"\bdist\b", "distance", RegexOptions.IgnoreCase);
            text = Regex.Replace(text, @"\bNAV\b", "Navigation", RegexOptions.IgnoreCase);
            text = Regex.Replace(text, @"\b([0-9]+)m\b", "$1 meters", RegexOptions.IgnoreCase);
            text = Regex.Replace(text, @"\b([0-9]+)ft\b", "$1 feet", RegexOptions.IgnoreCase);
            text = Regex.Replace(text, @"\b([0-9]+)\bbaud\b", "$1 baudrate", RegexOptions.IgnoreCase);

            if (MONO)
            {
                try
                {
                    //if (_speechlinux == null)
                    {
                        _state = SynthesizerState.Speaking;
                        _speechlinux = new System.Diagnostics.Process();
                        _speechlinux.StartInfo.RedirectStandardInput = true;
                        _speechlinux.StartInfo.UseShellExecute = false;
                        _speechlinux.StartInfo.FileName = "festival";
                        _speechlinux.Start();
                        _speechlinux.Exited += new EventHandler(_speechlinux_Exited);

                        log.Info("TTS: start " + _speechlinux.StartTime);

                    }

                    _state = SynthesizerState.Speaking;
                    _speechlinux.StandardInput.WriteLine("(SayText \"" + text + "\")");
                    _speechlinux.StandardInput.WriteLine("(quit)");

                    _speechlinux.Close();
                }
                catch { } // ignore errors

                _state = SynthesizerState.Ready;
            }
            else
            {
                if (_speechwindows != null)
                    _speechwindows.SpeakAsync(text);
            }

            log.Info("TTS: say " + text);
        }
Пример #7
0
        public Speech()
        {
            var t = Type.GetType("Mono.Runtime");
            MONO = (t != null);

            log.Info("TTS: init, mono = " + MONO);

            if (MONO)
            {
                _state = SynthesizerState.Ready;
            }
            else
            {
                _speechwindows = new SpeechSynthesizer();
            }
        }
Пример #8
0
        public Speech()
        {
            var t = Type.GetType("Mono.Runtime");

            MONO = (t != null);

            log.Info("TTS: init, mono = " + MONO);

            if (MONO)
            {
                _state = SynthesizerState.Ready;
            }
            else
            {
                _speechwindows = new SpeechSynthesizer();
            }
        }
Пример #9
0
 public void SpeakAsyncCancelAll()
 {
     if (MONO)
     {
         try
         {
             if (_speechlinux != null)
                 _speechlinux.Close();
         }
         catch { }
         _state = SynthesizerState.Ready;
     }
     else
     {
         try
         {
             if (_speechwindows!= null)
                 _speechwindows.SpeakAsyncCancelAll();
         }
         catch (System.PlatformNotSupportedException)
         {
             _speechwindows = null;
         }
         catch { }
     }
 }
Пример #10
0
 void _speechlinux_Exited(object sender, EventArgs e)
 {
     log.Info("TTS: exit " + _speechlinux.ExitTime);
     _state = SynthesizerState.Ready;
 }
Пример #11
0
 void _speechlinux_Exited(object sender, EventArgs e)
 {
     log.Info("TTS: exit " + _speechlinux.ExitTime);
     _state = SynthesizerState.Ready;
 }
Пример #12
0
 public void SpeakAsyncCancelAll()
 {
     if (MONO)
     {
         _speechlinux.Close();
         _state = SynthesizerState.Ready;
     }
     else
     {
         _speechwindows.SpeakAsyncCancelAll();
     }
 }
Пример #13
0
 public void SpeakAsyncCancelAll()
 {
     if (MONO)
     {
         try
         {
             if (_speechlinux != null)
                 _speechlinux.Close();
         }
         catch { }
         _state = SynthesizerState.Ready;
     }
     else
     {
         _speechwindows.SpeakAsyncCancelAll();
     }
 }