EddiSpeechService.SpeechServiceConfiguration.ToFile C# (CSharp) Method

ToFile() public method

public ToFile ( string filename = null ) : void
filename string
return void
        public void ToFile(string filename = null)
        {
            if (filename == null)
            {
                filename = dataPath;
            }
            if (filename == null)
            {
                filename = Constants.DATA_DIR + @"\speech.json";
            }

            string json = JsonConvert.SerializeObject(this, Formatting.Indented);
            File.WriteAllText(filename, json);
        }
    }

Usage Example

 /// <summary>
 /// fetch the Text-to-Speech Configuration and write it to File
 /// </summary>
 private void ttsUpdated()
 {
     SpeechServiceConfiguration speechConfiguration = new SpeechServiceConfiguration();
     speechConfiguration.StandardVoice = ttsVoiceDropDown.SelectedValue == null || ttsVoiceDropDown.SelectedValue.ToString() == "Windows TTS default" ? null : ttsVoiceDropDown.SelectedValue.ToString();
     speechConfiguration.Volume = (int)ttsVolumeSlider.Value;
     speechConfiguration.Rate = (int)ttsRateSlider.Value;
     speechConfiguration.EffectsLevel = (int)ttsEffectsLevelSlider.Value;
     speechConfiguration.DistortOnDamage = ttsDistortCheckbox.IsChecked.Value;
     speechConfiguration.DisableSsml = disableSsmlCheckbox.IsChecked.Value;
     speechConfiguration.ToFile();
     SpeechService.Instance.ReloadConfiguration();
 }
SpeechServiceConfiguration