This repository has been archived by the owner on Aug 28, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5e1d9be
commit 5662865
Showing
7 changed files
with
32 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -325,6 +325,7 @@ | |
"25763": 0.6, | ||
"25766": 0.6, | ||
"25768": 0.6, | ||
"25769": 0.6, | ||
"25771": 0.6, | ||
"25772": 0.6, | ||
"25773": 0.6, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,36 @@ | ||
using System.Diagnostics; | ||
using System.Text; | ||
using Dalamud.Plugin; | ||
using ECommons.DalamudServices; | ||
using ECommons.Reflection; | ||
using RotationSolver.Localization; | ||
|
||
namespace RotationSolver; | ||
|
||
internal static class SpeechHelper | ||
{ | ||
static IDalamudPlugin _textToTalk = null; | ||
static MethodInfo _say = null; | ||
static object _manager = null; | ||
static MethodInfo _stop = null; | ||
static bool _showed = false; | ||
internal static void Speak(string text) | ||
{ | ||
ExecuteCommand( | ||
$@"Add-Type -AssemblyName System.speech; | ||
$speak = New-Object System.Speech.Synthesis.SpeechSynthesizer; | ||
$speak.Volume = ""{Service.Config.VoiceVolume}""; | ||
$speak.Speak(""{text}"");"); | ||
|
||
static void ExecuteCommand(string command) | ||
if(_textToTalk == null) | ||
{ | ||
string path = Path.GetTempPath() + Guid.NewGuid() + ".ps1"; | ||
|
||
// make sure to be using System.Text | ||
using StreamWriter sw = new(path, false, Encoding.UTF8); | ||
sw.Write(command); | ||
|
||
ProcessStartInfo start = new() | ||
if (!DalamudReflector.TryGetDalamudPlugin("TextToTalk", out _textToTalk)) | ||
{ | ||
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); | ||
if (!_showed) | ||
{ | ||
_showed = true; | ||
Svc.Chat.PrintError(LocalizationManager.RightLang.TextToTalkWarning); | ||
} | ||
} | ||
} | ||
_say ??= _textToTalk?.GetType().GetRuntimeMethods().FirstOrDefault(m => m.Name == "Say"); | ||
_manager ??= _textToTalk?.GetType().GetRuntimeFields().FirstOrDefault(m => m.Name == "backendManager").GetValue(_textToTalk); | ||
_stop ??= _manager?.GetType().GetRuntimeMethods().FirstOrDefault(m => m.Name == "CancelAllSpeech"); | ||
|
||
|
||
_stop?.Invoke(_manager, Array.Empty<object>()); | ||
_say?.Invoke(_textToTalk, new object[] { null, text, 1 }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters