Exemple #1
0
        public SasaraSettings GetSasaraSettings()
        {
            this.StartSasara();

            var settings = new SasaraSettings();

            settings.Volume         = talker.Volume;
            settings.Speed          = talker.Speed;
            settings.Tone           = talker.Tone;
            settings.Alpha          = talker.Alpha;
            settings.Cast           = talker.Cast;
            settings.AvailableCasts = Talker.AvailableCasts;

            var compornents = new List <SasaraTalkerComponent>();

            for (int i = 0; i < talker.Components.Count; i++)
            {
                compornents.Add(new SasaraTalkerComponent()
                {
                    Id    = talker.Components[i].Id,
                    Name  = talker.Components[i].Name,
                    Value = talker.Components[i].Value,
                });
            }

            settings.Components = compornents.ToArray();

            return(settings);
        }
        /// <summary>
        /// ささらを設定する
        /// </summary>
        public void SetSasara()
        {
            var talker = new SasaraSettings();

            talker.Cast      = TTSYukkuriConfig.Default.SasaraSettings.Cast;
            talker.Volume    = TTSYukkuriConfig.Default.SasaraSettings.Onryo;
            talker.Speed     = TTSYukkuriConfig.Default.SasaraSettings.Hayasa;
            talker.Tone      = TTSYukkuriConfig.Default.SasaraSettings.Takasa;
            talker.Alpha     = TTSYukkuriConfig.Default.SasaraSettings.Seishitsu;
            talker.ToneScale = TTSYukkuriConfig.Default.SasaraSettings.Yokuyo;

            var components = new List <SasaraTalkerComponent>();

            foreach (var c in TTSYukkuriConfig.Default.SasaraSettings.Components)
            {
                components.Add(new SasaraTalkerComponent()
                {
                    Id    = c.Id,
                    Name  = c.Name,
                    Value = c.Value
                });
            }

            talker.Components = components.ToArray();

            // ささらに反映する
            TTSServerController.Message.SetSasaraSettings(new TTSMessage.SasaraSettingsEventArg()
            {
                Settings = talker
            });
        }
        public void SetSasaraSettings(
            SasaraSettings settings)
        {
            this.StartSasara();

            if (string.IsNullOrWhiteSpace(talker.Cast) &&
                Talker.AvailableCasts.Length > 0)
            {
                talker.Cast = Talker.AvailableCasts[0];
            }

            if (talker.Cast != settings.Cast ||
                talker.Volume != settings.Volume ||
                talker.Speed != settings.Speed ||
                talker.Tone != settings.Tone ||
                talker.Alpha != settings.Alpha ||
                talker.ToneScale != settings.ToneScale)
            {
                talker.Cast      = settings.Cast;
                talker.Volume    = settings.Volume;
                talker.Speed     = settings.Speed;
                talker.Tone      = settings.Tone;
                talker.Alpha     = settings.Alpha;
                talker.ToneScale = settings.ToneScale;
            }

            if (settings.Components != null)
            {
                foreach (var c in settings.Components)
                {
                    var t = talker.Components
                            .Where(x => x.Id == c.Id)
                            .FirstOrDefault();

                    if (t != null)
                    {
                        if (t.Value != c.Value)
                        {
                            t.Value = c.Value;
                        }
                    }
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// Load
        /// </summary>
        /// <param name="sender">イベント発生元</param>
        /// <param name="e">イベント引数</param>
        private void SasaraSettingsPanel_Load(object sender, EventArgs e)
        {
            this.talker = TTSServerController.Message.GetSasaraSettings();

            // キャストコンボボックスを設定する
            var casts = this.talker.AvailableCasts;

            this.castComboBox.Items.AddRange(casts);
            this.castComboBox.TextChanged += (s1, e1) =>
            {
                this.talker.Cast = this.castComboBox.Text;

                TTSServerController.Message.SetSasaraSettings(new TTSMessage.SasaraSettingsEventArg()
                {
                    Settings = this.talker
                });

                this.talker = TTSServerController.Message.GetSasaraSettings();

                var components = this.talker.Components;
                for (int i = 0; i < components.Length; i++)
                {
                    var c = components[i];

                    var component = this.componentsTable
                                    .Where(x => x.Id == c.Id)
                                    .FirstOrDefault();

                    if (component == null)
                    {
                        this.componentsTable.AddSasaraComponentsRow(
                            c.Id,
                            c.Name,
                            c.Value,
                            this.talker.Cast);
                    }
                }

                this.kanjoDataGridView.AutoGenerateColumns = false;
                this.kanjoDataGridView.DataSource          = componentsTable
                                                             .Where(x => x.Cast == this.talker.Cast)
                                                             .ToList();

                // 設定を保存する
                this.SaveSettings();
            };

            // 音量関係のテキストボックスを設定する
            this.onryoTextBox.Leave += (s1, e1) =>
            {
                this.ValidateParameter(s1 as TextBox);
            };

            this.hayasaTextBox.Leave += (s1, e1) =>
            {
                this.ValidateParameter(s1 as TextBox);
            };

            this.takasaTextBox.Leave += (s1, e1) =>
            {
                this.ValidateParameter(s1 as TextBox);
            };

            this.seishitsuTextBox.Leave += (s1, e1) =>
            {
                this.ValidateParameter(s1 as TextBox);
            };

            // 設定をロードする
            this.onryoTextBox.Text     = TTSYukkuriConfig.Default.SasaraSettings.Onryo.ToString();
            this.hayasaTextBox.Text    = TTSYukkuriConfig.Default.SasaraSettings.Hayasa.ToString();
            this.takasaTextBox.Text    = TTSYukkuriConfig.Default.SasaraSettings.Takasa.ToString();
            this.seishitsuTextBox.Text = TTSYukkuriConfig.Default.SasaraSettings.Seishitsu.ToString();
            this.componentsTable       = TTSYukkuriConfig.Default.SasaraSettings.Components;
            this.castComboBox.Text     = TTSYukkuriConfig.Default.SasaraSettings.Cast;

            // ささらを設定する
            TTSYukkuriConfig.Default.SetSasara();
        }