hermes-server/Requests/GetTTSVoices.cs

32 lines
996 B
C#

using HermesSocketLibrary.Requests.Messages;
using HermesSocketServer.Store;
using ILogger = Serilog.ILogger;
namespace HermesSocketServer.Requests
{
public class GetTTSVoices : IRequest
{
public string Name => "get_tts_voices";
public string[] RequiredKeys => [];
private VoiceStore _voices;
private ILogger _logger;
public GetTTSVoices(VoiceStore voices, ILogger logger)
{
_voices = voices;
_logger = logger;
}
public async Task<RequestResult> Grant(string sender, IDictionary<string, object>? data)
{
IEnumerable<VoiceDetails> voices = _voices.Get().Select(v => new VoiceDetails()
{
Id = v.Value.Id,
Name = v.Value.Name
});
_logger.Information($"Fetched all TTS voices for channel [channel: {sender}]");
return RequestResult.Successful(voices, notifyClientsOnAccount: false);
}
}
}