2024-06-16 20:19:31 -04:00
|
|
|
using System.Text.Json.Serialization;
|
2024-03-15 08:27:35 -04:00
|
|
|
using System.Text.RegularExpressions;
|
2024-06-16 20:19:31 -04:00
|
|
|
using HermesSocketLibrary.Requests.Messages;
|
2024-03-15 08:27:35 -04:00
|
|
|
|
|
|
|
namespace TwitchChatTTS
|
|
|
|
{
|
|
|
|
public class User
|
|
|
|
{
|
|
|
|
// Hermes user id
|
|
|
|
public string HermesUserId { get; set; }
|
2024-06-16 20:19:31 -04:00
|
|
|
public string HermesUsername { get; set; }
|
2024-03-15 08:27:35 -04:00
|
|
|
public long TwitchUserId { get; set; }
|
|
|
|
public string TwitchUsername { get; set; }
|
2024-06-16 20:19:31 -04:00
|
|
|
public string SevenEmoteSetId { get; set; }
|
2024-07-06 23:42:33 -04:00
|
|
|
public long? OwnerId { get; set; }
|
2024-06-16 20:19:31 -04:00
|
|
|
|
2024-03-15 08:27:35 -04:00
|
|
|
public string DefaultTTSVoice { get; set; }
|
|
|
|
// voice id -> voice name
|
2024-06-16 20:19:31 -04:00
|
|
|
public IDictionary<string, string> VoicesAvailable { get => _voicesAvailable; set { _voicesAvailable = value; WordFilterRegex = GenerateEnabledVoicesRegex(); } }
|
2024-07-06 23:42:33 -04:00
|
|
|
// chatter/twitch id -> voice id
|
2024-03-15 08:27:35 -04:00
|
|
|
public IDictionary<long, string> VoicesSelected { get; set; }
|
2024-06-16 20:19:31 -04:00
|
|
|
// voice names
|
|
|
|
public HashSet<string> VoicesEnabled { get => _voicesEnabled; set { _voicesEnabled = value; WordFilterRegex = GenerateEnabledVoicesRegex(); } }
|
2024-03-15 08:27:35 -04:00
|
|
|
|
|
|
|
public IDictionary<string, TTSUsernameFilter> ChatterFilters { get; set; }
|
2024-06-16 20:19:31 -04:00
|
|
|
public IList<TTSWordFilter> RegexFilters { get; set; }
|
|
|
|
[JsonIgnore]
|
|
|
|
public Regex? WordFilterRegex { get; set; }
|
|
|
|
|
|
|
|
private IDictionary<string, string> _voicesAvailable;
|
|
|
|
private HashSet<string> _voicesEnabled;
|
2024-03-15 08:27:35 -04:00
|
|
|
|
|
|
|
|
2024-06-16 20:19:31 -04:00
|
|
|
private Regex? GenerateEnabledVoicesRegex()
|
|
|
|
{
|
2024-03-15 08:27:35 -04:00
|
|
|
if (VoicesAvailable == null || VoicesAvailable.Count() <= 0)
|
|
|
|
return null;
|
|
|
|
|
2024-06-16 20:19:31 -04:00
|
|
|
var enabledVoicesString = string.Join("|", VoicesAvailable.Where(v => VoicesEnabled == null || !VoicesEnabled.Any() || VoicesEnabled.Contains(v.Value)).Select(v => v.Value));
|
2024-03-15 08:27:35 -04:00
|
|
|
return new Regex($@"\b({enabledVoicesString})\:(.*?)(?=\Z|\b(?:{enabledVoicesString})\:)", RegexOptions.IgnoreCase);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|