diff --git a/RotationSolver.Basic/Configuration/PluginConfiguration.cs b/RotationSolver.Basic/Configuration/PluginConfiguration.cs index 8f771a378..8afcc5b38 100644 --- a/RotationSolver.Basic/Configuration/PluginConfiguration.cs +++ b/RotationSolver.Basic/Configuration/PluginConfiguration.cs @@ -9,7 +9,6 @@ public class PluginConfiguration : IPluginConfiguration public int Version { get; set; } = 6; public int VoiceVolume = 100; - public string VoiceName = string.Empty; public SortedSet DisabledCombos { get; private set; } = new SortedSet(); public SortedSet DisabledActions { get; private set; } = new SortedSet(); public SortedSet NotInCoolDownActions { get; private set; } = new SortedSet(); diff --git a/RotationSolver/Localization/Strings.cs b/RotationSolver/Localization/Strings.cs index d364197f3..19ef9e9c1 100644 --- a/RotationSolver/Localization/Strings.cs +++ b/RotationSolver/Localization/Strings.cs @@ -147,7 +147,6 @@ internal partial class Strings public string ConfigWindow_Param_KeyBoardNoiseTimes { get; set; } = "Effect times"; public string ConfigWindow_Param_KeyBoardNoiseTime { get; set; } = "Effect interval"; public string ConfigWindow_Param_VoiceVolume { get; set; } = "Voice volume"; - public string ConfigWindow_Param_VoiceName { get; set; } = "Voice Name"; public string ConfigWindow_Param_FlytextPositional { get; set; } = "Hint positional anticipation by flytext"; public string ConfigWindow_Param_SayPositional { get; set; } = "Hint positional anticipation by shouting"; public string ConfigWindow_Param_PositionalFeedback { get; set; } = "Positional error feedback"; diff --git a/RotationSolver/SpeechHelper.cs b/RotationSolver/SpeechHelper.cs index 34f873a53..70ee46433 100644 --- a/RotationSolver/SpeechHelper.cs +++ b/RotationSolver/SpeechHelper.cs @@ -7,60 +7,34 @@ namespace RotationSolver; internal static class SpeechHelper { - static SpeechSynthesizer _speech; - public static string[] VoiceNames { get; private set; } - static bool _errored; internal static void Speak(string text) { - try - { - try - { - _speech ??= new SpeechSynthesizer(); - _speech.Volume = Service.Config.VoiceVolume; - _speech.SelectVoice(Service.Config.VoiceName); - VoiceNames ??= _speech.GetInstalledVoices().Select(v => v.VoiceInfo.Name).ToArray(); - } - catch (Exception ex) - { - if (!_errored) - { - _errored = true; - PluginLog.Error(ex, "Speech Exception"); - } - } - _speech.SpeakAsyncCancelAll(); - _speech.SpeakAsync(text); - } - catch - { - ExecuteCommand( - $@"Add-Type -AssemblyName System.speech; + ExecuteCommand( + $@"Add-Type -AssemblyName System.speech; $speak = New-Object System.Speech.Synthesis.SpeechSynthesizer; $speak.Volume = ""{Service.Config.VoiceVolume}""; $speak.Speak(""{text}"");"); - void ExecuteCommand(string command) + void ExecuteCommand(string command) + { + string path = Path.GetTempPath() + Guid.NewGuid() + ".ps1"; + + // make sure to be using System.Text + using (StreamWriter sw = new StreamWriter(path, false, Encoding.UTF8)) { - string path = Path.GetTempPath() + Guid.NewGuid() + ".ps1"; + sw.Write(command); - // make sure to be using System.Text - using (StreamWriter sw = new StreamWriter(path, false, Encoding.UTF8)) + ProcessStartInfo start = new ProcessStartInfo() { - sw.Write(command); - - ProcessStartInfo start = new ProcessStartInfo() - { - FileName = @"C:\Windows\System32\windowspowershell\v1.0\powershell.exe", - LoadUserProfile = false, - UseShellExecute = false, - CreateNoWindow = true, - Arguments = $"-executionpolicy bypass -File {path}", - WindowStyle = ProcessWindowStyle.Hidden - }; + FileName = @"C:\Windows\System32\windowspowershell\v1.0\powershell.exe", + LoadUserProfile = false, + UseShellExecute = false, + CreateNoWindow = true, + Arguments = $"-executionpolicy bypass -File {path}", + WindowStyle = ProcessWindowStyle.Hidden + }; - Process process = Process.Start(start); - } + Process process = Process.Start(start); } } } diff --git a/RotationSolver/UI/RotationConfigWindow_Param.cs b/RotationSolver/UI/RotationConfigWindow_Param.cs index 6b4e47d45..6a217cbf9 100644 --- a/RotationSolver/UI/RotationConfigWindow_Param.cs +++ b/RotationSolver/UI/RotationConfigWindow_Param.cs @@ -127,22 +127,6 @@ private void DrawParamAdvanced() DrawIntNumber(LocalizationManager.RightLang.ConfigWindow_Param_VoiceVolume, ref Service.Config.VoiceVolume, Service.Default.VoiceVolume, max: 100); - if(SpeechHelper.VoiceNames != null) - { - if (ImGui.BeginCombo(LocalizationManager.RightLang.ConfigWindow_Param_VoiceName, Service.Config.VoiceName)) - { - foreach (var item in SpeechHelper.VoiceNames) - { - if (ImGui.Selectable(item)) - { - Service.Config.VoiceName = item; - Service.Config.Save(); - } - } - ImGui.EndCombo(); - } - } - DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_SayOutStateChanged, ref Service.Config.SayOutStateChanged, Service.Default.SayOutStateChanged);