Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
fix: removed the Voice Name feature.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Apr 10, 2023
1 parent a0e49a1 commit 328d286
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 62 deletions.
1 change: 0 additions & 1 deletion RotationSolver.Basic/Configuration/PluginConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> DisabledCombos { get; private set; } = new SortedSet<string>();
public SortedSet<uint> DisabledActions { get; private set; } = new SortedSet<uint>();
public SortedSet<uint> NotInCoolDownActions { get; private set; } = new SortedSet<uint>();
Expand Down
1 change: 0 additions & 1 deletion RotationSolver/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
62 changes: 18 additions & 44 deletions RotationSolver/SpeechHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down
16 changes: 0 additions & 16 deletions RotationSolver/UI/RotationConfigWindow_Param.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 328d286

Please sign in to comment.