47 lines
1.4 KiB
C#
47 lines
1.4 KiB
C#
|
using Serilog;
|
||
|
|
||
|
namespace TwitchChatTTS.Hermes.Socket.Requests
|
||
|
{
|
||
|
public class UpdateTTSVoiceAck : IRequestAck
|
||
|
{
|
||
|
public string Name => "update_tts_voice";
|
||
|
private readonly User _user;
|
||
|
private readonly ILogger _logger;
|
||
|
|
||
|
public UpdateTTSVoiceAck(User user, ILogger logger)
|
||
|
{
|
||
|
_user = user;
|
||
|
_logger = logger;
|
||
|
}
|
||
|
|
||
|
public void Acknowledge(string requestId, string json, IDictionary<string, object>? requestData)
|
||
|
{
|
||
|
if (requestData == null)
|
||
|
{
|
||
|
_logger.Warning("Request data is null.");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
var voice = requestData["voice"].ToString();
|
||
|
var voiceId = requestData["idd"].ToString();
|
||
|
if (string.IsNullOrEmpty(voice))
|
||
|
{
|
||
|
_logger.Warning("Voice name is invalid.");
|
||
|
return;
|
||
|
}
|
||
|
if (string.IsNullOrEmpty(voiceId))
|
||
|
{
|
||
|
_logger.Warning("Voice Id is invalid.");
|
||
|
return;
|
||
|
}
|
||
|
if (_user.VoicesAvailable.ContainsKey(voiceId))
|
||
|
{
|
||
|
_logger.Warning($"Voice Id already exists [voice id: {voiceId}]");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
_user.VoicesAvailable[voiceId] = voice;
|
||
|
_logger.Information($"Created a new tts voice [voice id: {voiceId}][voice name: {voice}]");
|
||
|
}
|
||
|
}
|
||
|
}
|