33 lines
1.0 KiB
C#
33 lines
1.0 KiB
C#
using HermesSocketLibrary.Requests.Messages;
|
|
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;
|
|
}
|
|
|
|
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,
|
|
});
|
|
|
|
_logger.Information($"Fetched all TTS voices for channel [channel: {channel.Id}]");
|
|
return Task.FromResult(RequestResult.Successful(voices, notifyClientsOnAccount: false));
|
|
}
|
|
}
|
|
} |