4 implementations of ITextToSpeechClient
Microsoft.Extensions.AI.Abstractions (1)
TextToSpeech\DelegatingTextToSpeechClient.cs (1)
22public class DelegatingTextToSpeechClient : ITextToSpeechClient
Microsoft.Extensions.AI.Abstractions.Tests (1)
TestTextToSpeechClient.cs (1)
11public sealed class TestTextToSpeechClient : ITextToSpeechClient
Microsoft.Extensions.AI.OpenAI (1)
OpenAITextToSpeechClient.cs (1)
23internal sealed class OpenAITextToSpeechClient : ITextToSpeechClient
Microsoft.Extensions.AI.Tests (1)
parent\Microsoft.Extensions.AI.Abstractions.Tests\TestTextToSpeechClient.cs (1)
11public sealed class TestTextToSpeechClient : ITextToSpeechClient
143 references to ITextToSpeechClient
Microsoft.Extensions.AI (41)
TextToSpeech\ConfigureOptionsTextToSpeechClient.cs (1)
33public ConfigureOptionsTextToSpeechClient(ITextToSpeechClient innerClient, Action<TextToSpeechOptions> configure)
TextToSpeech\LoggingTextToSpeechClient.cs (3)
20/// The provided implementation of <see cref="ITextToSpeechClient"/> is thread-safe for concurrent use so long as the 40/// <param name="innerClient">The underlying <see cref="ITextToSpeechClient"/>.</param> 42public LoggingTextToSpeechClient(ITextToSpeechClient innerClient, ILogger logger)
TextToSpeech\OpenTelemetryTextToSpeechClient.cs (2)
44/// <param name="innerClient">The underlying <see cref="ITextToSpeechClient"/>.</param> 47public OpenTelemetryTextToSpeechClient(ITextToSpeechClient innerClient, ILogger? logger = null, string? sourceName = null)
TextToSpeech\TextToSpeechClientBuilder.cs (18)
12/// <summary>A builder for creating pipelines of <see cref="ITextToSpeechClient"/>.</summary> 16private readonly Func<IServiceProvider, ITextToSpeechClient> _innerClientFactory; 19private List<Func<ITextToSpeechClient, IServiceProvider, ITextToSpeechClient>>? _clientFactories; 22/// <param name="innerClient">The inner <see cref="ITextToSpeechClient"/> that represents the underlying backend.</param> 23public TextToSpeechClientBuilder(ITextToSpeechClient innerClient) 30/// <param name="innerClientFactory">A callback that produces the inner <see cref="ITextToSpeechClient"/> that represents the underlying backend.</param> 31public TextToSpeechClientBuilder(Func<IServiceProvider, ITextToSpeechClient> innerClientFactory) 36/// <summary>Builds an <see cref="ITextToSpeechClient"/> that represents the entire pipeline. Calls to this instance will pass through each of the pipeline stages in turn.</summary> 38/// The <see cref="IServiceProvider"/> that should provide services to the <see cref="ITextToSpeechClient"/> instances. 41/// <returns>An instance of <see cref="ITextToSpeechClient"/> that represents the entire pipeline.</returns> 42public ITextToSpeechClient Build(IServiceProvider? services = null) 45var client = _innerClientFactory(services); 55$"Ensure that the callbacks passed to {nameof(Use)} return non-null {nameof(ITextToSpeechClient)} instances."); 65public TextToSpeechClientBuilder Use(Func<ITextToSpeechClient, ITextToSpeechClient> clientFactory) 75public TextToSpeechClientBuilder Use(Func<ITextToSpeechClient, IServiceProvider, ITextToSpeechClient> clientFactory)
TextToSpeech\TextToSpeechClientBuilderServiceCollectionExtensions.cs (15)
12/// <summary>Provides extension methods for registering <see cref="ITextToSpeechClient"/> with a <see cref="IServiceCollection"/>.</summary> 16/// <summary>Registers a singleton <see cref="ITextToSpeechClient"/> in the <see cref="IServiceCollection"/>.</summary> 18/// <param name="innerClient">The inner <see cref="ITextToSpeechClient"/> that represents the underlying backend.</param> 24ITextToSpeechClient innerClient, 32/// <summary>Registers a singleton <see cref="ITextToSpeechClient"/> in the <see cref="IServiceCollection"/>.</summary> 34/// <param name="innerClientFactory">A callback that produces the inner <see cref="ITextToSpeechClient"/> that represents the underlying backend.</param> 40Func<IServiceProvider, ITextToSpeechClient> innerClientFactory, 47serviceCollection.Add(new ServiceDescriptor(typeof(ITextToSpeechClient), builder.Build, lifetime)); 51/// <summary>Registers a keyed singleton <see cref="ITextToSpeechClient"/> in the <see cref="IServiceCollection"/>.</summary> 54/// <param name="innerClient">The inner <see cref="ITextToSpeechClient"/> that represents the underlying backend.</param> 61ITextToSpeechClient innerClient, 69/// <summary>Registers a keyed singleton <see cref="ITextToSpeechClient"/> in the <see cref="IServiceCollection"/>.</summary> 72/// <param name="innerClientFactory">A callback that produces the inner <see cref="ITextToSpeechClient"/> that represents the underlying backend.</param> 79Func<IServiceProvider, ITextToSpeechClient> innerClientFactory, 86serviceCollection.Add(new ServiceDescriptor(typeof(ITextToSpeechClient), serviceKey, factory: (services, serviceKey) => builder.Build(services), lifetime));
TextToSpeech\TextToSpeechClientBuilderTextToSpeechClientExtensions.cs (2)
10/// <summary>Provides extension methods for working with <see cref="ITextToSpeechClient"/> in the context of <see cref="TextToSpeechClientBuilder"/>.</summary> 21public static TextToSpeechClientBuilder AsBuilder(this ITextToSpeechClient innerClient)
Microsoft.Extensions.AI.Abstractions (23)
TextToSpeech\DelegatingTextToSpeechClient.cs (5)
15/// Provides an optional base class for an <see cref="ITextToSpeechClient"/> that passes through calls to another instance. 18/// This is recommended as a base type when building clients that can be chained in any order around an underlying <see cref="ITextToSpeechClient"/>. 28protected DelegatingTextToSpeechClient(ITextToSpeechClient innerClient) 40/// <summary>Gets the inner <see cref="ITextToSpeechClient" />.</summary> 41protected ITextToSpeechClient InnerClient { get; }
TextToSpeech\ITextToSpeechClient.cs (6)
16/// Unless otherwise specified, all members of <see cref="ITextToSpeechClient"/> are thread-safe for concurrent use. 17/// It is expected that all implementations of <see cref="ITextToSpeechClient"/> support being used by multiple requests concurrently. 20/// However, implementations of <see cref="ITextToSpeechClient"/> might mutate the arguments supplied to <see cref="GetAudioAsync"/> and 23/// <see cref="ITextToSpeechClient"/> instances are used which might employ such mutation. For example, the ConfigureOptions method may be 52/// <summary>Asks the <see cref="ITextToSpeechClient"/> for an object of the specified type <paramref name="serviceType"/>.</summary> 58/// The purpose of this method is to allow for the retrieval of strongly typed services that might be provided by the <see cref="ITextToSpeechClient"/>,
TextToSpeech\TextToSpeechClientExtensions.cs (4)
10/// <summary>Extensions for <see cref="ITextToSpeechClient"/>.</summary> 14/// <summary>Asks the <see cref="ITextToSpeechClient"/> for an object of type <typeparamref name="TService"/>.</summary> 20/// The purpose of this method is to allow for the retrieval of strongly typed services that may be provided by the <see cref="ITextToSpeechClient"/>, 23public static TService? GetService<TService>(this ITextToSpeechClient client, object? serviceKey = null)
TextToSpeech\TextToSpeechClientMetadata.cs (1)
10/// <summary>Provides metadata about an <see cref="ITextToSpeechClient"/>.</summary>
TextToSpeech\TextToSpeechOptions.cs (6)
85/// The underlying <see cref="ITextToSpeechClient" /> implementation may have its own representation of options. 86/// When <see cref="ITextToSpeechClient.GetAudioAsync" /> or <see cref="ITextToSpeechClient.GetStreamingAudioAsync"/> 89/// which concrete <see cref="ITextToSpeechClient" /> is being used and how it represents options, a new instance of that 90/// implementation-specific options type may be returned by this callback, for the <see cref="ITextToSpeechClient" /> 98public Func<ITextToSpeechClient, object?>? RawRepresentationFactory { get; set; }
TextToSpeech\TextToSpeechResponseUpdate.cs (1)
13/// Represents a single streaming response chunk from an <see cref="ITextToSpeechClient"/>.
Microsoft.Extensions.AI.Abstractions.Tests (4)
TextToSpeech\DelegatingTextToSpeechClientTests.cs (3)
125var client = delegating.GetService<ITextToSpeechClient>(expectedKey); 161private sealed class NoOpDelegatingTextToSpeechClient(ITextToSpeechClient innerClient)
TextToSpeech\TextToSpeechOptionsTests.cs (1)
46Func<ITextToSpeechClient?, object?> rawRepresentationFactory = (c) => null;
Microsoft.Extensions.AI.Integration.Tests (2)
TextToSpeechClientIntegrationTests.cs (2)
16private readonly ITextToSpeechClient? _client; 29protected abstract ITextToSpeechClient? CreateClient();
Microsoft.Extensions.AI.OpenAI (4)
OpenAIClientExtensions.cs (3)
171/// <summary>Gets an <see cref="ITextToSpeechClient"/> for use with this <see cref="AudioClient"/>.</summary> 173/// <returns>An <see cref="ITextToSpeechClient"/> that can be used to generate speech via the <see cref="AudioClient"/>.</returns> 176public static ITextToSpeechClient AsITextToSpeechClient(this AudioClient audioClient) =>
OpenAITextToSpeechClient.cs (1)
21/// <summary>Represents an <see cref="ITextToSpeechClient"/> for an OpenAI <see cref="OpenAIClient"/> or <see cref="AudioClient"/>.</summary>
Microsoft.Extensions.AI.OpenAI.Tests (17)
OpenAITextToSpeechClientIntegrationTests.cs (2)
14protected override ITextToSpeechClient? CreateClient() 25using ITextToSpeechClient client = openAIClient
OpenAITextToSpeechClientTests.cs (15)
38ITextToSpeechClient ttsClient = client.GetAudioClient(model).AsITextToSpeechClient(); 49ITextToSpeechClient ttsClient = audioClient.AsITextToSpeechClient(); 50Assert.Same(ttsClient, ttsClient.GetService<ITextToSpeechClient>()); 53using ITextToSpeechClient pipeline = ttsClient 61Assert.IsType<LoggingTextToSpeechClient>(pipeline.GetService<ITextToSpeechClient>()); 79using ITextToSpeechClient client = CreateTextToSpeechClient(httpClient, "tts-1"); 107using ITextToSpeechClient client = CreateTextToSpeechClient(httpClient, "tts-1"); 136using ITextToSpeechClient client = CreateTextToSpeechClient(httpClient, "tts-1"); 169using ITextToSpeechClient client = CreateTextToSpeechClient(httpClient, "tts-1"); 199using ITextToSpeechClient client = CreateTextToSpeechClient(httpClient, "tts-1"); 222using ITextToSpeechClient client = CreateTextToSpeechClient(httpClient, "tts-1"); 235using ITextToSpeechClient client = CreateTextToSpeechClient(httpClient, "tts-1"); 263using ITextToSpeechClient client = CreateTextToSpeechClient(httpClient, "tts-1"); 308using ITextToSpeechClient client = CreateTextToSpeechClient(httpClient, "gpt-4o-mini-tts"); 343private static ITextToSpeechClient CreateTextToSpeechClient(HttpClient httpClient, string modelId) =>
Microsoft.Extensions.AI.Tests (52)
TextToSpeech\ConfigureOptionsTextToSpeechClientTests.cs (2)
41using ITextToSpeechClient ttsInnerClient = new TestTextToSpeechClient 58using var client = ttsInnerClient
TextToSpeech\LoggingTextToSpeechClientTests.cs (17)
30Assert.Same(innerClient, innerClient.AsBuilder().UseLogging(NullLoggerFactory.Instance).Build().GetService(typeof(ITextToSpeechClient))); 55using ITextToSpeechClient innerClient = new TestTextToSpeechClient 63using ITextToSpeechClient client = innerClient 78entry => Assert.True(entry.Message.Contains($"{nameof(ITextToSpeechClient.GetAudioAsync)} invoked:") && entry.Message.Contains("\"voiceId\": \"alloy\"")), 79entry => Assert.Contains($"{nameof(ITextToSpeechClient.GetAudioAsync)} completed.", entry.Message)); 84entry => Assert.True(entry.Message.Contains($"{nameof(ITextToSpeechClient.GetAudioAsync)} invoked.") && !entry.Message.Contains("\"voiceId\": \"alloy\"")), 85entry => Assert.Contains($"{nameof(ITextToSpeechClient.GetAudioAsync)} completed.", entry.Message)); 102using ITextToSpeechClient innerClient = new TestTextToSpeechClient 114using ITextToSpeechClient client = innerClient 132entry => Assert.True(entry.Message.Contains($"{nameof(ITextToSpeechClient.GetStreamingAudioAsync)} invoked:") && entry.Message.Contains("\"voiceId\": \"alloy\"")), 133entry => Assert.Contains($"{nameof(ITextToSpeechClient.GetStreamingAudioAsync)} received update.", entry.Message), 134entry => Assert.Contains($"{nameof(ITextToSpeechClient.GetStreamingAudioAsync)} received update.", entry.Message), 135entry => Assert.Contains($"{nameof(ITextToSpeechClient.GetStreamingAudioAsync)} completed.", entry.Message)); 140entry => Assert.True(entry.Message.Contains($"{nameof(ITextToSpeechClient.GetStreamingAudioAsync)} invoked.") && !entry.Message.Contains("voiceId")), 141entry => Assert.Contains($"{nameof(ITextToSpeechClient.GetStreamingAudioAsync)} received update.", entry.Message), 142entry => Assert.Contains($"{nameof(ITextToSpeechClient.GetStreamingAudioAsync)} received update.", entry.Message), 143entry => Assert.Contains($"{nameof(ITextToSpeechClient.GetStreamingAudioAsync)} completed.", entry.Message));
TextToSpeech\OpenTelemetryTextToSpeechClientTests.cs (2)
82using var client = innerClient 159using var client = innerClient
TextToSpeech\TextToSpeechClientDependencyInjectionPatterns.cs (31)
26var instance1 = scope1.ServiceProvider.GetRequiredService<ITextToSpeechClient>(); 27var instance1Copy = scope1.ServiceProvider.GetRequiredService<ITextToSpeechClient>(); 28var instance2 = scope2.ServiceProvider.GetRequiredService<ITextToSpeechClient>(); 50var instance1 = scope1.ServiceProvider.GetRequiredService<ITextToSpeechClient>(); 51var instance1Copy = scope1.ServiceProvider.GetRequiredService<ITextToSpeechClient>(); 52var instance2 = scope2.ServiceProvider.GetRequiredService<ITextToSpeechClient>(); 73Assert.Null(services.GetService<ITextToSpeechClient>()); 75var instance1 = scope1.ServiceProvider.GetRequiredKeyedService<ITextToSpeechClient>("mykey"); 76var instance1Copy = scope1.ServiceProvider.GetRequiredKeyedService<ITextToSpeechClient>("mykey"); 77var instance2 = scope2.ServiceProvider.GetRequiredKeyedService<ITextToSpeechClient>("mykey"); 99Assert.Null(services.GetService<ITextToSpeechClient>()); 101var instance1 = scope1.ServiceProvider.GetRequiredKeyedService<ITextToSpeechClient>("mykey"); 102var instance1Copy = scope1.ServiceProvider.GetRequiredKeyedService<ITextToSpeechClient>("mykey"); 103var instance2 = scope2.ServiceProvider.GetRequiredKeyedService<ITextToSpeechClient>("mykey"); 126Assert.Equal(typeof(ITextToSpeechClient), sd.ServiceType); 148Assert.Equal(typeof(ITextToSpeechClient), sd.ServiceType); 164Assert.Equal(typeof(ITextToSpeechClient), sd.ServiceType); 173public class SingletonMiddleware(ITextToSpeechClient inner, IServiceProvider services) : DelegatingTextToSpeechClient(inner) 175public new ITextToSpeechClient InnerClient => base.InnerClient;