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

Commit

Permalink
fix: changed the speech logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Mar 19, 2023
1 parent 549c0e5 commit 3b7d169
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 21 deletions.
1 change: 1 addition & 0 deletions RotationSolver.Basic/Configuration/PluginConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ 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> DisabledItems { get; private set; } = new SortedSet<uint>();
Expand Down
5 changes: 3 additions & 2 deletions RotationSolver/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,10 @@ internal partial class Strings
public string ConfigWindow_Param_TeachingModeColor { get; set; } = "Prompt box color of teaching mode";
public string ConfigWindow_Param_MovingTargetColor { get; set; } = "Prompt box color of moving target";
public string ConfigWindow_Param_TargetColor { get; set; } = "Target color";
public string ConfigWindow_Params_SubTargetColor { get; set; } = "Sub-target color";
public string ConfigWindow_Param_SubTargetColor { get; set; } = "Sub-target color";
public string ConfigWindow_Param_KeyBoardNoise { get; set; } = "Simulate the effect of pressing";
public string ConfigWindow_Params_VoiceVolume { get; set; } = "Voice volume";
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
20 changes: 14 additions & 6 deletions RotationSolver/SpeechHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using RotationSolver.Basic;
using Dalamud.Logging;
using RotationSolver.Basic;
using System.Diagnostics;
using System.Speech.Synthesis;
using System.Text;
Expand All @@ -8,17 +9,24 @@ namespace RotationSolver;
internal static class SpeechHelper
{
static SpeechSynthesizer _speech;
public static string[] VoiceNames { get; private set; }
internal static void Speak(string text)
{
try
{
_speech ??= new SpeechSynthesizer();
_speech.Volume = Service.Config.VoiceVolume;
try
{
VoiceNames ??= _speech.GetInstalledVoices().Select(v => v.VoiceInfo.Name).ToArray();
_speech ??= new SpeechSynthesizer();
_speech.Volume = Service.Config.VoiceVolume;
_speech.SelectVoice(Service.Config.VoiceName);
}
catch(Exception ex)
{
PluginLog.Error(ex, "Speech Exception");
}
_speech.SpeakAsyncCancelAll();
_speech.SpeakAsync(text);

//When I got win 11, I'll do that.
//_speech.GetInstalledVoices().FirstOrDefault().VoiceInfo;
}
catch
{
Expand Down
26 changes: 19 additions & 7 deletions RotationSolver/UI/RotationConfigWindow_Param.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,24 @@ private void DrawParamDelay()

private void DrawParamAdvanced()
{
DrawIntNumber(LocalizationManager.RightLang.ConfigWindow_Params_VoiceVolume,
ref Service.Config.VoiceVolume, max: 100);
DrawIntNumber(LocalizationManager.RightLang.ConfigWindow_Param_VoiceVolume,
ref Service.Config.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);
Expand Down Expand Up @@ -169,10 +185,6 @@ private void DrawParamAdvanced()

DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Param_ShowActionFlag,
ref Service.Config.ShowActionFlag);

ImGui.Separator();


}

private void DrawParamDisplay()
Expand Down Expand Up @@ -215,7 +227,7 @@ private void DrawParamDisplay()

ImGuiHelper.Spacing();

DrawColor3(LocalizationManager.RightLang.ConfigWindow_Params_SubTargetColor,
DrawColor3(LocalizationManager.RightLang.ConfigWindow_Param_SubTargetColor,
ref Service.Config.SubTargetColor);
}
}
Expand Down
6 changes: 0 additions & 6 deletions RotationSolver/Updaters/MajorUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
using Dalamud.Logging;
using RotationSolver.Basic;
using RotationSolver.Commands;
using RotationSolver.SigReplacers;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using System.Threading.Tasks.Dataflow;

namespace RotationSolver.Updaters;

Expand Down

0 comments on commit 3b7d169

Please sign in to comment.