/// <summary> /// Change the personality for the speech responder /// </summary> /// <returns>true if the speech responder is now using the new personality, otherwise false</returns> public bool SetPersonality(string newPersonality) { SpeechResponderConfiguration configuration = SpeechResponderConfiguration.FromFile(); if (newPersonality == configuration.Personality) { // Already set to this personality return(true); } // Ensure that this personality exists Personality personality = Personality.FromName(newPersonality); if (personality != null) { // Yes it does; use it configuration.Personality = newPersonality; configuration.ToFile(); scriptResolver = new ScriptResolver(personality.Scripts); Logging.Debug("Changed personality to " + newPersonality); return(true); } else { // No it does not; ignore it return(false); } }
private void subtitlesOnlyDisabled(object sender, RoutedEventArgs e) { SpeechResponderConfiguration configuration = SpeechResponderConfiguration.FromFile(); configuration.SubtitlesOnly = false; configuration.ToFile(); EDDI.Instance.Reload("Speech responder"); }
/// <summary> /// Obtain configuration from a file. If the file name is not supplied the the default /// path of Constants.Data_DIR\speechresponder.json is used /// </summary> public static SpeechResponderConfiguration FromFile(string filename = null) { if (filename == null) { filename = Constants.DATA_DIR + @"\speechresponder.json"; } SpeechResponderConfiguration configuration = new SpeechResponderConfiguration(); try { configuration = JsonConvert.DeserializeObject <SpeechResponderConfiguration>(File.ReadAllText(filename)); } catch (Exception ex) { Logging.Debug("Failed to read speech responder configuration", ex); } if (configuration.Personality == null) { configuration.Personality = "EDDI"; configuration.ToFile(); } configuration.dataPath = filename; return(configuration); }
private void personalityChanged(object sender, SelectionChangedEventArgs e) { if (Personality != null) { SpeechResponderConfiguration configuration = SpeechResponderConfiguration.FromFile(); configuration.Personality = Personality.Name; configuration.ToFile(); EDDI.Instance.Reload("Speech responder"); } }
private void subtitlesOnlyEnabled(object sender, RoutedEventArgs e) { if (sender is CheckBox checkBox) { if (checkBox.IsLoaded) { SpeechResponderConfiguration configuration = SpeechResponderConfiguration.FromFile(); configuration.SubtitlesOnly = true; configuration.ToFile(); EDDI.Instance.Reload("Speech responder"); } } }
public void Reload() { SpeechResponderConfiguration configuration = SpeechResponderConfiguration.FromFile(); Personality personality = Personality.FromName(configuration.Personality); if (personality == null) { Logging.Warn("Failed to find named personality; falling back to default"); personality = Personality.Default(); configuration.Personality = personality.Name; configuration.ToFile(); } scriptResolver = new ScriptResolver(personality.Scripts); Logging.Info("Reloaded " + ResponderName() + " " + ResponderVersion()); }
public void Reload() { SpeechResponderConfiguration configuration = SpeechResponderConfiguration.FromFile(); Personality personality = Personality.FromName(configuration.Personality); if (personality == null) { Logging.Warn("Failed to find named personality; falling back to default"); personality = Personality.Default(); configuration.Personality = personality.Name; configuration.ToFile(); } scriptResolver = new ScriptResolver(personality.Scripts); subtitles = configuration.Subtitles; subtitlesOnly = configuration.SubtitlesOnly; Logging.Debug($"Reloaded {ResponderName()}"); }
/// <summary> /// Obtain configuration from a file. If the file name is not supplied the the default /// path of Constants.Data_DIR\speechresponder.json is used /// </summary> public static SpeechResponderConfiguration FromFile(string filename = null) { if (filename == null) { filename = Constants.DATA_DIR + @"\speechresponder.json"; } SpeechResponderConfiguration configuration = new SpeechResponderConfiguration(); try { configuration = JsonConvert.DeserializeObject<SpeechResponderConfiguration>(File.ReadAllText(filename)); } catch { } if (configuration.Personality == null) { configuration.Personality = "EDDI"; configuration.ToFile(); } configuration.dataPath = filename; return configuration; }