Example #1
0
        public PluginSettings(object ParentSettingsClass) : base(ParentSettingsClass)
        {
            _settingsIo.WriteSettings = writer =>
            {
                writer.WriteStartElement("SettingsSerializer");
                ExportToXml(writer);
                writer.WriteEndElement();

                writer.Serialize(Playback);
                writer.Serialize(BaiduTtsSettings);
            };

            _settingsIo.ReadSettings = reader =>
            {
                switch (reader.LocalName)
                {
                case "SettingsSerializer":
                    ImportFromXml(reader);
                    break;

                case nameof(PlaybackSettings):
                    Playback = reader.Deserialize <PlaybackSettings>();
                    break;

                case nameof(BaiduTTSSettings):
                    BaiduTtsSettings = reader.Deserialize <BaiduTTSSettings>();
                    break;
                }
            };
        }
Example #2
0
        public void Load()
        {
            if (File.Exists(_settingsFile))
            {
                FileStream fs = new FileStream(_settingsFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);

                XmlTextReader reader = new XmlTextReader(fs);
                while (reader.Read())
                {
                    if (reader.NodeType != XmlNodeType.Element)
                    {
                        continue;
                    }

                    switch (reader.LocalName)
                    {
                    case "SettingsSerializer":
                        ImportFromXml(reader);
                        break;

                    case nameof(PlaybackSettings):
                        Playback = Deserialize <PlaybackSettings>(reader);
                        break;

                    case nameof(BaiduTTSSettings):
                        BaiduTtsSettings = Deserialize <BaiduTTSSettings>(reader);
                        break;
                    }
                }

                reader.Close();
            }
        }
Example #3
0
        public void Play(string waveFile, dynamic playDevice, bool isSync, float?volume)
        {
            PlaybackSettings settings = _plugin.Settings.PlaybackSettings;

            switch (settings.Method)
            {
            case PlaybackMethod.Yukkuri:
                _plugin.TtsInjector.PlayTTSYukkuri(waveFile, playDevice, isSync, volume);
                break;

            case PlaybackMethod.Act:
                // Play sound with ACT's sound API
                ActGlobals.oFormActMain.PlaySoundWmpApi(waveFile, settings.MasterVolume);
                break;
            }
        }
        public void Play(string waveFile, dynamic playDevice, bool isSync, float?volume)
        {
            PlaybackSettings settings = _plugin.Settings.PlaybackSettings;

            switch (settings.Method)
            {
            case PlaybackMethod.Yukkuri:
                _plugin.TtsInjector.PlayTTSYukkuri(waveFile, playDevice, isSync, volume);
                break;

            case PlaybackMethod.Act:
                // Play sound with ACT's sound API
                ActGlobals.oFormActMain.PlaySoundWmpApi(waveFile, settings.MasterVolume);
                break;

            case PlaybackMethod.BuiltIn:
                // Use built-in api to play sounds
                // atm we support WMM only
                // And WMM needs to be called in main thread
                ActGlobals.oFormActMain.SafeInvoke(new Action(() => _wmm.PlaySound(waveFile)));
                break;
            }
        }
Example #5
0
        public PluginSettings(object ParentSettingsClass) : base(ParentSettingsClass)
        {
            _settingsIo.WriteSettings = writer =>
            {
                writer.WriteStartElement("SettingsSerializer");
                ExportToXml(writer);
                writer.WriteEndElement();

                writer.Serialize(Playback);
                writer.Serialize(PreProcessorSettings);
                writer.Serialize(CafeTtsSettings);
                writer.Serialize(BaiduTtsSettings);
                writer.Serialize(SApi5Settings);
                writer.Serialize(BaipiaoSettings);
                writer.Serialize(EdgeTtsSettings);
                writer.Serialize(GoogleUnofficialTtsSettings);
                writer.Serialize(YoudaoTtsSettings);
                writer.Serialize(XfyunTtsSettings);
            };

            _settingsIo.ReadSettings = reader =>
            {
                switch (reader.LocalName)
                {
                case "SettingsSerializer":
                    ImportFromXml(reader);
                    break;

                case nameof(PlaybackSettings):
                    Playback = reader.Deserialize <PlaybackSettings>();
                    break;

                case nameof(preprocess.PreProcessorSettings):
                    PreProcessorSettings = reader.Deserialize <PreProcessorSettings>();
                    break;

                case nameof(CafeTTSSettings):
                    CafeTtsSettings = reader.Deserialize <CafeTTSSettings>();
                    break;

                case nameof(BaiduTTSSettings):
                    BaiduTtsSettings = reader.Deserialize <BaiduTTSSettings>();
                    BaiduTtsSettings.RemoveFreeKey();
                    break;

                case nameof(SAPI5Settings):
                    SApi5Settings = reader.Deserialize <SAPI5Settings>();
                    break;

                case nameof(engine.baipiao.BaipiaoSettings):
                    BaipiaoSettings = reader.Deserialize <BaipiaoSettings>();
                    break;

                case nameof(EdgeTTSSettings):
                    EdgeTtsSettings = reader.Deserialize <EdgeTTSSettings>();
                    break;

                case nameof(GoogleUnofficialTTSSettings):
                    GoogleUnofficialTtsSettings = reader.Deserialize <GoogleUnofficialTTSSettings>();
                    break;

                case nameof(YoudaoTTSSettings):
                    YoudaoTtsSettings = reader.Deserialize <YoudaoTTSSettings>();
                    break;

                case nameof(XfyunTTSSettings):
                    XfyunTtsSettings = reader.Deserialize <XfyunTTSSettings>();
                    break;
                }
            };
        }