Skip to content

Commit

Permalink
进一步修复系统 TTS 不存在导致崩溃的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
STBBRD committed Aug 15, 2024
1 parent 2fec0d2 commit 1fa0ca1
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions ZongziTEK_Blackboard_Sticker/StrongNotificationWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public StrongNotificationWindow(string title, string subtitle)
}
}

private SpeechSynthesizer synthesizer;
private SpeechSynthesizer synthesizer = null;

private async void Window_Loaded(object sender, RoutedEventArgs e)
{
Expand Down Expand Up @@ -71,9 +71,12 @@ private async void Window_Loaded(object sender, RoutedEventArgs e)
await Task.Delay(500);

// 语音播报
synthesizer.Speak(TextBlockTitle.Text);
await Task.Delay(200);
synthesizer.Speak(TextBlockSubtitle.Text);
if (synthesizer != null)
{
synthesizer.Speak(TextBlockTitle.Text);
await Task.Delay(200);
synthesizer.Speak(TextBlockSubtitle.Text);
}

// 退出动画
DoubleAnimation opacityAnimationOut = new()
Expand Down

0 comments on commit 1fa0ca1

Please sign in to comment.