From 0904e9101d0961835ee2a2c8656c2fd3c048c322 Mon Sep 17 00:00:00 2001 From: T'kael Date: Fri, 13 Aug 2021 00:14:39 -0700 Subject: [PATCH] Docs and tidy up --- EDDI/ChangeLog.md | 3 ++- SpeechService/SpeechService.cs | 16 +++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/EDDI/ChangeLog.md b/EDDI/ChangeLog.md index 01fd2f74e0..62da62b6bb 100644 --- a/EDDI/ChangeLog.md +++ b/EDDI/ChangeLog.md @@ -5,7 +5,8 @@ Full details of the variables available for each noted event, and VoiceAttack in ### 4.0.1-b4 * Core * Added a speculative fix for a bug that could prevent speech when the same voice is available from multiple speech synthesizers. - + * Refactored to try to improve compatibility with older Windows versions. + ### 4.0.1-b3 * Core * Fixed a bug that would cause speech volume for some voices to be either 0% or 100%. diff --git a/SpeechService/SpeechService.cs b/SpeechService/SpeechService.cs index 664c1c1a5a..56203dac15 100644 --- a/SpeechService/SpeechService.cs +++ b/SpeechService/SpeechService.cs @@ -119,13 +119,19 @@ private SpeechService() var voiceStore = new HashSet(); // Use a Hashset to ensure no duplicates // Windows.Media.SpeechSynthesis isn't available on older Windows versions so we must check if we have access - var temp = RuntimeEnvironment.GetSystemVersion(); - if (ApiInformation.IsTypePresent("Windows.Media.SpeechSynthesis.SpeechSynthesizer")) + try { - // Prep the Windows.Media.SpeechSynthesis synthesizer - windowsMediaSynth = new WindowsMediaSynthesizer(ref voiceStore); + if (ApiInformation.IsTypePresent("Windows.Media.SpeechSynthesis.SpeechSynthesizer")) + { + // Prep the Windows.Media.SpeechSynthesis synthesizer + windowsMediaSynth = new WindowsMediaSynthesizer(ref voiceStore); + } } - + catch (Exception e) + { + Logging.Warn($"Unable to initialize Windows.Media.SpeechSynthesis.SpeechSynthesizer, {RuntimeInformation.OSDescription}", e); + } + // Prep the System.Speech synthesizer systemSpeechSynth = new SystemSpeechSynthesizer(ref voiceStore);