예제 #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;
        }
예제 #2
0
 public void Dispose()
 {
     if (this.synthesizer != null)
     {
         this.synthesizer.Dispose();
         this.synthesizer = null;
     }
 }