hermes-server/Requests/GetTTSVoices.cs

33 lines
1.0 KiB
C#
Raw Normal View History

using HermesSocketLibrary.Requests.Messages;
2024-12-27 23:31:36 +00:00
using HermesSocketServer.Models;
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;
}
2024-12-28 17:24:02 +00:00
public Task<RequestResult> Grant(Channel channel, IDictionary<string, object> data)
{
IEnumerable<TTSVoice> voices = _voices.Get().Select(v => new TTSVoice()
{
Id = v.Value.Id,
Name = v.Value.Name,
});
2024-12-27 23:31:36 +00:00
_logger.Information($"Fetched all TTS voices for channel [channel: {channel.Id}]");
2024-12-28 17:24:02 +00:00
return Task.FromResult(RequestResult.Successful(voices, notifyClientsOnAccount: false));
}
}
}