4 implementations of ITextToSpeechClient
Microsoft.Extensions.AI.Abstractions (1)
TextToSpeech\DelegatingTextToSpeechClient.cs (1)
22
public class DelegatingTextToSpeechClient :
ITextToSpeechClient
Microsoft.Extensions.AI.Abstractions.Tests (1)
TestTextToSpeechClient.cs (1)
11
public sealed class TestTextToSpeechClient :
ITextToSpeechClient
Microsoft.Extensions.AI.OpenAI (1)
OpenAITextToSpeechClient.cs (1)
23
internal sealed class OpenAITextToSpeechClient :
ITextToSpeechClient
Microsoft.Extensions.AI.Tests (1)
parent\Microsoft.Extensions.AI.Abstractions.Tests\TestTextToSpeechClient.cs (1)
11
public sealed class TestTextToSpeechClient :
ITextToSpeechClient
143 references to ITextToSpeechClient
Microsoft.Extensions.AI (41)
TextToSpeech\ConfigureOptionsTextToSpeechClient.cs (1)
33
public 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>
42
public LoggingTextToSpeechClient(
ITextToSpeechClient
innerClient, ILogger logger)
TextToSpeech\OpenTelemetryTextToSpeechClient.cs (2)
44
/// <param name="innerClient">The underlying <see cref="
ITextToSpeechClient
"/>.</param>
47
public 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>
16
private readonly Func<IServiceProvider,
ITextToSpeechClient
> _innerClientFactory;
19
private List<Func<
ITextToSpeechClient
, IServiceProvider,
ITextToSpeechClient
>>? _clientFactories;
22
/// <param name="innerClient">The inner <see cref="
ITextToSpeechClient
"/> that represents the underlying backend.</param>
23
public TextToSpeechClientBuilder(
ITextToSpeechClient
innerClient)
30
/// <param name="innerClientFactory">A callback that produces the inner <see cref="
ITextToSpeechClient
"/> that represents the underlying backend.</param>
31
public 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>
42
public
ITextToSpeechClient
Build(IServiceProvider? services = null)
45
var
client = _innerClientFactory(services);
55
$"Ensure that the callbacks passed to {nameof(Use)} return non-null {nameof(
ITextToSpeechClient
)} instances.");
65
public TextToSpeechClientBuilder Use(Func<
ITextToSpeechClient
,
ITextToSpeechClient
> clientFactory)
75
public 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>
24
ITextToSpeechClient
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>
40
Func<IServiceProvider,
ITextToSpeechClient
> innerClientFactory,
47
serviceCollection.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>
61
ITextToSpeechClient
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>
79
Func<IServiceProvider,
ITextToSpeechClient
> innerClientFactory,
86
serviceCollection.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>
21
public 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
"/>.
28
protected DelegatingTextToSpeechClient(
ITextToSpeechClient
innerClient)
40
/// <summary>Gets the inner <see cref="
ITextToSpeechClient
" />.</summary>
41
protected
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
"/>,
23
public 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
" />
98
public 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)
125
var
client = delegating.GetService<
ITextToSpeechClient
>(expectedKey);
161
private sealed class NoOpDelegatingTextToSpeechClient(
ITextToSpeechClient
innerClient)
TextToSpeech\TextToSpeechOptionsTests.cs (1)
46
Func<
ITextToSpeechClient
?, object?> rawRepresentationFactory = (c) => null;
Microsoft.Extensions.AI.Integration.Tests (2)
TextToSpeechClientIntegrationTests.cs (2)
16
private readonly
ITextToSpeechClient
? _client;
29
protected 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>
176
public 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)
14
protected override
ITextToSpeechClient
? CreateClient()
25
using
ITextToSpeechClient
client = openAIClient
OpenAITextToSpeechClientTests.cs (15)
38
ITextToSpeechClient
ttsClient = client.GetAudioClient(model).AsITextToSpeechClient();
49
ITextToSpeechClient
ttsClient = audioClient.AsITextToSpeechClient();
50
Assert.Same(ttsClient, ttsClient.GetService<
ITextToSpeechClient
>());
53
using
ITextToSpeechClient
pipeline = ttsClient
61
Assert.IsType<LoggingTextToSpeechClient>(pipeline.GetService<
ITextToSpeechClient
>());
79
using
ITextToSpeechClient
client = CreateTextToSpeechClient(httpClient, "tts-1");
107
using
ITextToSpeechClient
client = CreateTextToSpeechClient(httpClient, "tts-1");
136
using
ITextToSpeechClient
client = CreateTextToSpeechClient(httpClient, "tts-1");
169
using
ITextToSpeechClient
client = CreateTextToSpeechClient(httpClient, "tts-1");
199
using
ITextToSpeechClient
client = CreateTextToSpeechClient(httpClient, "tts-1");
222
using
ITextToSpeechClient
client = CreateTextToSpeechClient(httpClient, "tts-1");
235
using
ITextToSpeechClient
client = CreateTextToSpeechClient(httpClient, "tts-1");
263
using
ITextToSpeechClient
client = CreateTextToSpeechClient(httpClient, "tts-1");
308
using
ITextToSpeechClient
client = CreateTextToSpeechClient(httpClient, "gpt-4o-mini-tts");
343
private static
ITextToSpeechClient
CreateTextToSpeechClient(HttpClient httpClient, string modelId) =>
Microsoft.Extensions.AI.Tests (52)
TextToSpeech\ConfigureOptionsTextToSpeechClientTests.cs (2)
41
using
ITextToSpeechClient
ttsInnerClient = new TestTextToSpeechClient
58
using
var
client = ttsInnerClient
TextToSpeech\LoggingTextToSpeechClientTests.cs (17)
30
Assert.Same(innerClient, innerClient.AsBuilder().UseLogging(NullLoggerFactory.Instance).Build().GetService(typeof(
ITextToSpeechClient
)));
55
using
ITextToSpeechClient
innerClient = new TestTextToSpeechClient
63
using
ITextToSpeechClient
client = innerClient
78
entry => Assert.True(entry.Message.Contains($"{nameof(
ITextToSpeechClient
.GetAudioAsync)} invoked:") && entry.Message.Contains("\"voiceId\": \"alloy\"")),
79
entry => Assert.Contains($"{nameof(
ITextToSpeechClient
.GetAudioAsync)} completed.", entry.Message));
84
entry => Assert.True(entry.Message.Contains($"{nameof(
ITextToSpeechClient
.GetAudioAsync)} invoked.") && !entry.Message.Contains("\"voiceId\": \"alloy\"")),
85
entry => Assert.Contains($"{nameof(
ITextToSpeechClient
.GetAudioAsync)} completed.", entry.Message));
102
using
ITextToSpeechClient
innerClient = new TestTextToSpeechClient
114
using
ITextToSpeechClient
client = innerClient
132
entry => Assert.True(entry.Message.Contains($"{nameof(
ITextToSpeechClient
.GetStreamingAudioAsync)} invoked:") && entry.Message.Contains("\"voiceId\": \"alloy\"")),
133
entry => Assert.Contains($"{nameof(
ITextToSpeechClient
.GetStreamingAudioAsync)} received update.", entry.Message),
134
entry => Assert.Contains($"{nameof(
ITextToSpeechClient
.GetStreamingAudioAsync)} received update.", entry.Message),
135
entry => Assert.Contains($"{nameof(
ITextToSpeechClient
.GetStreamingAudioAsync)} completed.", entry.Message));
140
entry => Assert.True(entry.Message.Contains($"{nameof(
ITextToSpeechClient
.GetStreamingAudioAsync)} invoked.") && !entry.Message.Contains("voiceId")),
141
entry => Assert.Contains($"{nameof(
ITextToSpeechClient
.GetStreamingAudioAsync)} received update.", entry.Message),
142
entry => Assert.Contains($"{nameof(
ITextToSpeechClient
.GetStreamingAudioAsync)} received update.", entry.Message),
143
entry => Assert.Contains($"{nameof(
ITextToSpeechClient
.GetStreamingAudioAsync)} completed.", entry.Message));
TextToSpeech\OpenTelemetryTextToSpeechClientTests.cs (2)
82
using
var
client = innerClient
159
using
var
client = innerClient
TextToSpeech\TextToSpeechClientDependencyInjectionPatterns.cs (31)
26
var
instance1 = scope1.ServiceProvider.GetRequiredService<
ITextToSpeechClient
>();
27
var
instance1Copy = scope1.ServiceProvider.GetRequiredService<
ITextToSpeechClient
>();
28
var
instance2 = scope2.ServiceProvider.GetRequiredService<
ITextToSpeechClient
>();
50
var
instance1 = scope1.ServiceProvider.GetRequiredService<
ITextToSpeechClient
>();
51
var
instance1Copy = scope1.ServiceProvider.GetRequiredService<
ITextToSpeechClient
>();
52
var
instance2 = scope2.ServiceProvider.GetRequiredService<
ITextToSpeechClient
>();
73
Assert.Null(services.GetService<
ITextToSpeechClient
>());
75
var
instance1 = scope1.ServiceProvider.GetRequiredKeyedService<
ITextToSpeechClient
>("mykey");
76
var
instance1Copy = scope1.ServiceProvider.GetRequiredKeyedService<
ITextToSpeechClient
>("mykey");
77
var
instance2 = scope2.ServiceProvider.GetRequiredKeyedService<
ITextToSpeechClient
>("mykey");
99
Assert.Null(services.GetService<
ITextToSpeechClient
>());
101
var
instance1 = scope1.ServiceProvider.GetRequiredKeyedService<
ITextToSpeechClient
>("mykey");
102
var
instance1Copy = scope1.ServiceProvider.GetRequiredKeyedService<
ITextToSpeechClient
>("mykey");
103
var
instance2 = scope2.ServiceProvider.GetRequiredKeyedService<
ITextToSpeechClient
>("mykey");
126
Assert.Equal(typeof(
ITextToSpeechClient
), sd.ServiceType);
148
Assert.Equal(typeof(
ITextToSpeechClient
), sd.ServiceType);
164
Assert.Equal(typeof(
ITextToSpeechClient
), sd.ServiceType);
173
public class SingletonMiddleware(
ITextToSpeechClient
inner, IServiceProvider services) : DelegatingTextToSpeechClient(inner)
175
public new
ITextToSpeechClient
InnerClient => base.InnerClient;