using System.Runtime.CompilerServices; namespace Robovoice.Core; public interface ITtsEngine : IAsyncDisposable { string Name { get; } int SampleRate { get; } Task InitializeAsync(CancellationToken ct = default); IAsyncEnumerable SynthesizeAsync( string text, CancellationToken ct = default); } public static class TtsEngineExtensions { public static ConfiguredCancelableAsyncEnumerable SynthesizeAsync( this ITtsEngine engine, string text, CancellationToken ct = default) { return engine.SynthesizeAsync(text, ct).ConfigureAwait(false).WithCancellation(ct); } }