From dd0017f94ff303616ebb00f84f0460657046f0b1 Mon Sep 17 00:00:00 2001
From: FN <37689533+FireNameFN@users.noreply.github.com>
Date: Mon, 25 Nov 2024 13:48:26 +0700
Subject: [PATCH] Possible TTS fix 2 (#51)
* Possible TTS fix 2
* Fix
---
Content.Client/Corvax/TTS/TTSSystem.cs | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/Content.Client/Corvax/TTS/TTSSystem.cs b/Content.Client/Corvax/TTS/TTSSystem.cs
index fa41aa8bc4c..3b800a72a35 100644
--- a/Content.Client/Corvax/TTS/TTSSystem.cs
+++ b/Content.Client/Corvax/TTS/TTSSystem.cs
@@ -22,9 +22,11 @@ public sealed class TTSSystem : EntitySystem
[Dependency] private readonly AudioSystem _audio = default!;
private ISawmill _sawmill = default!;
- private MemoryContentRoot _contentRoot = default!;
+ private static MemoryContentRoot _contentRoot = new();
private static readonly ResPath Prefix = ResPath.Root / "TTS";
+ private static bool _contentRootAdded;
+
///
/// Reducing the volume of the TTS when whispering. Will be converted to logarithm.
///
@@ -40,9 +42,13 @@ public sealed class TTSSystem : EntitySystem
public override void Initialize()
{
- _contentRoot = new();
+ if (!_contentRootAdded)
+ {
+ _contentRootAdded = true;
+ _res.AddRoot(Prefix, _contentRoot);
+ }
+
_sawmill = Logger.GetSawmill("tts");
- _res.AddRoot(Prefix, _contentRoot);
_cfg.OnValueChanged(CCCVars.TTSVolume, OnTtsVolumeChanged, true);
SubscribeNetworkEvent(OnPlayTTS);
}
@@ -51,7 +57,6 @@ public override void Shutdown()
{
base.Shutdown();
_cfg.UnsubValueChanged(CCCVars.TTSVolume, OnTtsVolumeChanged);
- _contentRoot.Dispose();
}
public void RequestPreviewTTS(string voiceId)