Fixed TTS using StreamElements. Fixed several issues.

This commit is contained in:
Tom
2026-01-03 05:19:33 +00:00
parent fb04f4003f
commit aa89578297
16 changed files with 275 additions and 135 deletions

View File

@@ -33,8 +33,7 @@ namespace TwitchChatTTS.Hermes.Socket.Handlers
if (message.AnotherClient)
{
if (client.LoggedIn)
_logger.Warning($"Another client has connected to the same account via {(message.WebLogin ? "web login" : "application")}.");
_logger.Warning($"Another client has connected to the same account via {(message.WebLogin ? "web login" : "application")}.");
return;
}
if (client.LoggedIn)
@@ -51,6 +50,7 @@ namespace TwitchChatTTS.Hermes.Socket.Handlers
_user.TwitchUsername = message.UserName;
_user.TwitchUserId = long.Parse(message.ProviderAccountId);
_user.OwnerId = message.OwnerId;
_user.StreamElementsOverlayKey = message.StreamElementsOverlayKey;
_user.DefaultTTSVoice = message.DefaultTTSVoice;
_user.VoicesAvailable = new ConcurrentDictionary<string, string>(message.TTSVoicesAvailable);
_user.VoicesEnabled = new HashSet<string>(message.EnabledTTSVoices);
@@ -58,7 +58,7 @@ namespace TwitchChatTTS.Hermes.Socket.Handlers
_user.NightbotConnection = message.Connections.FirstOrDefault(c => c.Default && c.Type == "nightbot") ?? message.Connections.FirstOrDefault(c => c.Type == "nightbot");
if (_user.TwitchConnection != null)
{
_logger.Information("Twitch connection: " + _user.TwitchConnection.Name + " / " + _user.TwitchConnection.AccessToken);
_logger.Debug("Twitch connection: " + _user.TwitchConnection.Name + " / " + _user.TwitchConnection.AccessToken);
}
var filters = message.WordFilters.Where(f => f.Search != null && f.Replace != null).ToList();
@@ -101,8 +101,9 @@ namespace TwitchChatTTS.Hermes.Socket.Handlers
}
_logger.Information("TTS is now ready.");
_bus.Send(this, "tts_connected", _user);
client.Ready = true;
_bus.Send(this, "tts_connected", _user);
}
}
}

View File

@@ -82,35 +82,36 @@ namespace TwitchChatTTS.Hermes.Socket
public override async Task Connect()
{
_rwls.EnterWriteLock();
_rwls.EnterReadLock();
try
{
if (Connected)
return;
_logger.Debug($"Attempting to connect to {URL}");
await ConnectAsync(URL);
}
finally
{
_rwls.ExitWriteLock();
_rwls.ExitReadLock();
}
_logger.Debug($"Attempting to connect to {URL}");
await ConnectAsync(URL);
}
private async Task Disconnect()
{
_rwls.EnterWriteLock();
_rwls.EnterReadLock();
try
{
if (!Connected)
return;
await DisconnectAsync(new SocketDisconnectionEventArgs("Normal disconnection", "Disconnection was executed"));
}
finally
{
_rwls.ExitWriteLock();
_rwls.ExitReadLock();
}
await DisconnectAsync(new SocketDisconnectionEventArgs("Normal disconnection", "Disconnection was executed"));
}
public async Task CreateTTSVoice(string voiceName)
@@ -437,13 +438,13 @@ namespace TwitchChatTTS.Hermes.Socket
_logger.Warning("Tom to Speech websocket client is not connected. Not sending a message.");
return;
}
await base.Send(opcode, message);
}
finally
{
_rwls.ExitReadLock();
}
await base.Send(opcode, message);
}
}
}

View File

@@ -1,4 +1,3 @@
using System.Text.Json;
using Serilog;
using TwitchChatTTS.Chat.Groups;
@@ -8,13 +7,11 @@ namespace TwitchChatTTS.Hermes.Socket.Requests
{
public string Name => "delete_group";
private readonly IChatterGroupManager _groups;
private readonly JsonSerializerOptions _options;
private readonly ILogger _logger;
public DeleteGroupAck(IChatterGroupManager groups, JsonSerializerOptions options, ILogger logger)
public DeleteGroupAck(IChatterGroupManager groups, ILogger logger)
{
_groups = groups;
_options = options;
_logger = logger;
}