From 8619fa6db97fa3a1f231824fdab98d34418015af Mon Sep 17 00:00:00 2001 From: rampaa Date: Wed, 25 Dec 2024 20:14:22 +0300 Subject: [PATCH] Minor --- JL.Windows/SpeechSynthesis/SpeechSynthesisUtils.cs | 4 +++- JL.Windows/Utilities/MagpieUtils.cs | 6 ++++++ JL.Windows/WinApi.cs | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/JL.Windows/SpeechSynthesis/SpeechSynthesisUtils.cs b/JL.Windows/SpeechSynthesis/SpeechSynthesisUtils.cs index a8bdfa40..f31248f5 100644 --- a/JL.Windows/SpeechSynthesis/SpeechSynthesisUtils.cs +++ b/JL.Windows/SpeechSynthesis/SpeechSynthesisUtils.cs @@ -91,13 +91,15 @@ public static async Task TextToSpeech(string voiceName, string text) _ = Synthesizer.SpeakAsync(text); } - public static byte[]? GetAudioResponseFromTextToSpeech(string text) + public static async Task GetAudioResponseFromTextToSpeech(string text) { if (InstalledVoiceWithHighestPriority is null) { return null; } + await StopTextToSpeech().ConfigureAwait(false); + Synthesizer.SelectVoice(InstalledVoiceWithHighestPriority); using MemoryStream audioDataStream = new(); Synthesizer.SetOutputToWaveStream(audioDataStream); diff --git a/JL.Windows/Utilities/MagpieUtils.cs b/JL.Windows/Utilities/MagpieUtils.cs index 2152077e..87dffe00 100644 --- a/JL.Windows/Utilities/MagpieUtils.cs +++ b/JL.Windows/Utilities/MagpieUtils.cs @@ -9,6 +9,7 @@ internal static class MagpieUtils public static double MagpieWindowTopEdgePosition { get; set; } public static double MagpieWindowBottomEdgePosition { get; set; } public static double DpiAwareMagpieWindowWidth { get; set; } + // public static nint SourceWindowHandle { get; set; } public static void RegisterToMagpieScalingChangedMessage(nint windowHandle) { @@ -46,6 +47,11 @@ public static double GetMagpieWindowBottomEdgePosition(nint windowHandle) return WinApi.GetProp(windowHandle, "Magpie.DestBottom"); } + //public static nint GetSourceWindowHande(nint windowHandle) + //{ + // return WinApi.GetProp(windowHandle, "Magpie.SrcHWND"); + //} + // If Magpie crashes or is killed during the process of scaling a window, // JL will not receive the MagpieScalingChangedWindowMessage. // Consequently, IsMagpieScaling may not be set to false. diff --git a/JL.Windows/WinApi.cs b/JL.Windows/WinApi.cs index 869a0cc5..e3079d64 100644 --- a/JL.Windows/WinApi.cs +++ b/JL.Windows/WinApi.cs @@ -349,6 +349,7 @@ private nint WndProc(nint hwnd, int msg, nint wParam, nint lParam, ref bool hand MagpieUtils.MagpieWindowBottomEdgePosition = MagpieUtils.GetMagpieWindowBottomEdgePosition(lParam); MagpieUtils.MagpieWindowLeftEdgePosition = MagpieUtils.GetMagpieWindowLeftEdgePosition(lParam); MagpieUtils.MagpieWindowRightEdgePosition = MagpieUtils.GetMagpieWindowRightEdgePosition(lParam); + // MagpieUtils.SourceWindowHandle = MagpieUtils.GetSourceWindowHande(lParam); MagpieUtils.DpiAwareMagpieWindowWidth = (MagpieUtils.MagpieWindowRightEdgePosition - MagpieUtils.MagpieWindowLeftEdgePosition) / WindowsUtils.Dpi.DpiScaleX; MainWindow.Instance.BringToFront(); }