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
61c69ea
commit 5df63d2
Showing
19 changed files
with
182 additions
and
146 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
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
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using RotationSolver.Basic; | ||
using System.Diagnostics; | ||
using System.Speech.Synthesis; | ||
using System.Text; | ||
|
||
namespace RotationSolver; | ||
|
||
internal static class SpeechHelper | ||
{ | ||
static SpeechSynthesizer _speech; | ||
internal static void Speak(string text) | ||
{ | ||
try | ||
{ | ||
_speech ??= new SpeechSynthesizer(); | ||
_speech.Volume = Service.Config.VoiceVolume; | ||
_speech.SpeakAsyncCancelAll(); | ||
_speech.SpeakAsync(text); | ||
|
||
//When I got win 11, I'll do that. | ||
//_speech.GetInstalledVoices().FirstOrDefault().VoiceInfo; | ||
} | ||
catch | ||
{ | ||
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) | ||
{ | ||
string path = Path.GetTempPath() + Guid.NewGuid() + ".ps1"; | ||
|
||
// make sure to be using System.Text | ||
using (StreamWriter sw = new StreamWriter(path, false, Encoding.UTF8)) | ||
{ | ||
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 | ||
}; | ||
|
||
Process process = Process.Start(start); | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.