Beispiel #1
0
        private void PopulateSynthesizer()
        {
            var synthesizerWrapper = new SynthesizerWrapper();

            if (this.Name.ToUpper() == "TTSYUKKURI")
            {
                if (TTSYukkuriPlugin == null)
                {
                    if (ActGlobals.oFormActMain.Visible)
                    {
                        foreach (var item in ActGlobals.oFormActMain.ActPlugins)
                        {
                            if (item.pluginFile.Name.ToUpper() == "ACT.TTSYukkuri.dll".ToUpper() &&
                                item.lblPluginStatus.Text.ToUpper() == "Plugin Started".ToUpper())
                            {
                                TTSYukkuriPlugin = item.pluginObj;
                                break;
                            }
                        }
                    }
                }

                if (TTSYukkuriPlugin != null)
                {
                    // スピークdelegateにゆっくりプラグインを割り当てる
                    synthesizerWrapper.SpeakAsyncByYukkuriDelegate = (textToSpeak) =>
                    {
                        TTSYukkuriPlugin.Speak(textToSpeak);
                    };
                }
            }
            else
            {
                // 標準のTTSを割り当てる
                synthesizerWrapper.Synthesizer = new SpeechSynthesizer();

                if (!string.IsNullOrEmpty(this.VoiceName))
                {
                    try
                    {
                        synthesizerWrapper.Synthesizer.SelectVoice(this.VoiceName);
                    }
                    catch (Exception)
                    {
                        MessageBox.Show(string.Format(
                                            "The selected TTS engine '{1}' at the speaker named '{0}' is not installed on your system.",
                                            this.Name,
                                            this.VoiceName));
                    }
                }

                synthesizerWrapper.Synthesizer.Rate   = this.Rate;
                synthesizerWrapper.Synthesizer.Volume = this.Volume;

                synthesizerWrapper.SpeakAsyncDelegate = synthesizerWrapper.Synthesizer.SpeakAsync;
            }

            this.synthesizer = synthesizerWrapper;
        }
Beispiel #2
0
 public void Dispose()
 {
     if (this.synthesizer != null)
     {
         this.synthesizer.Dispose();
         this.synthesizer = null;
     }
 }