2024-06-24 18:21:59 -04:00
|
|
|
using HermesSocketLibrary.db;
|
|
|
|
using HermesSocketLibrary.Requests;
|
|
|
|
using HermesSocketLibrary.Requests.Messages;
|
|
|
|
using ILogger = Serilog.ILogger;
|
|
|
|
|
|
|
|
namespace HermesSocketServer.Requests
|
|
|
|
{
|
|
|
|
public class GetTTSVoices : IRequest
|
|
|
|
{
|
|
|
|
public string Name => "get_tts_voices";
|
|
|
|
private Database _database;
|
|
|
|
private ILogger _logger;
|
|
|
|
|
|
|
|
public GetTTSVoices(Database database, ILogger logger)
|
|
|
|
{
|
|
|
|
_database = database;
|
|
|
|
_logger = logger;
|
|
|
|
}
|
|
|
|
|
2024-08-10 15:36:32 -04:00
|
|
|
public async Task<RequestResult> Grant(string sender, IDictionary<string, object>? data)
|
2024-06-24 18:21:59 -04:00
|
|
|
{
|
|
|
|
IList<VoiceDetails> voices = new List<VoiceDetails>();
|
|
|
|
string sql = "SELECT id, name FROM \"TtsVoice\"";
|
2024-08-10 15:36:32 -04:00
|
|
|
await _database.Execute(sql, (IDictionary<string, object>?) null, (r) => voices.Add(new VoiceDetails()
|
2024-06-24 18:21:59 -04:00
|
|
|
{
|
|
|
|
Id = r.GetString(0),
|
|
|
|
Name = r.GetString(1)
|
|
|
|
}));
|
2024-08-10 15:36:32 -04:00
|
|
|
_logger.Information($"Fetched all TTS voices for channel [channel: {sender}]");
|
2024-06-24 18:21:59 -04:00
|
|
|
return new RequestResult(true, voices, notifyClientsOnAccount: false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|