5 implementations of ISpeechToTextClient
Microsoft.Extensions.AI.Abstractions (1)
SpeechToText\DelegatingSpeechToTextClient.cs (1)
22
public class DelegatingSpeechToTextClient :
ISpeechToTextClient
Microsoft.Extensions.AI.Abstractions.Tests (1)
TestSpeechToTextClient.cs (1)
12
public sealed class TestSpeechToTextClient :
ISpeechToTextClient
Microsoft.Extensions.AI.Integration.Tests (1)
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\TestSpeechToTextClient.cs (1)
12
public sealed class TestSpeechToTextClient :
ISpeechToTextClient
Microsoft.Extensions.AI.OpenAI (1)
OpenAISpeechToTextClient.cs (1)
22
internal sealed class OpenAISpeechToTextClient :
ISpeechToTextClient
Microsoft.Extensions.AI.Tests (1)
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\TestSpeechToTextClient.cs (1)
12
public sealed class TestSpeechToTextClient :
ISpeechToTextClient
143 references to ISpeechToTextClient
Microsoft.Extensions.AI (41)
SpeechToText\ConfigureOptionsSpeechToTextClient.cs (1)
33
public ConfigureOptionsSpeechToTextClient(
ISpeechToTextClient
innerClient, Action<SpeechToTextOptions> configure)
SpeechToText\LoggingSpeechToTextClient.cs (3)
20
/// The provided implementation of <see cref="
ISpeechToTextClient
"/> is thread-safe for concurrent use so long as the
40
/// <param name="innerClient">The underlying <see cref="
ISpeechToTextClient
"/>.</param>
42
public LoggingSpeechToTextClient(
ISpeechToTextClient
innerClient, ILogger logger)
SpeechToText\OpenTelemetrySpeechToTextClient.cs (2)
42
/// <param name="innerClient">The underlying <see cref="
ISpeechToTextClient
"/>.</param>
46
public OpenTelemetrySpeechToTextClient(
ISpeechToTextClient
innerClient, ILogger? logger = null, string? sourceName = null)
SpeechToText\SpeechToTextClientBuilder.cs (18)
11
/// <summary>A builder for creating pipelines of <see cref="
ISpeechToTextClient
"/>.</summary>
15
private readonly Func<IServiceProvider,
ISpeechToTextClient
> _innerClientFactory;
18
private List<Func<
ISpeechToTextClient
, IServiceProvider,
ISpeechToTextClient
>>? _clientFactories;
21
/// <param name="innerClient">The inner <see cref="
ISpeechToTextClient
"/> that represents the underlying backend.</param>
22
public SpeechToTextClientBuilder(
ISpeechToTextClient
innerClient)
29
/// <param name="innerClientFactory">A callback that produces the inner <see cref="
ISpeechToTextClient
"/> that represents the underlying backend.</param>
30
public SpeechToTextClientBuilder(Func<IServiceProvider,
ISpeechToTextClient
> innerClientFactory)
35
/// <summary>Builds an <see cref="
ISpeechToTextClient
"/> that represents the entire pipeline. Calls to this instance will pass through each of the pipeline stages in turn.</summary>
37
/// The <see cref="IServiceProvider"/> that should provide services to the <see cref="
ISpeechToTextClient
"/> instances.
40
/// <returns>An instance of <see cref="
ISpeechToTextClient
"/> that represents the entire pipeline.</returns>
41
public
ISpeechToTextClient
Build(IServiceProvider? services = null)
44
var
audioClient = _innerClientFactory(services);
54
$"Ensure that the callbacks passed to {nameof(Use)} return non-null {nameof(
ISpeechToTextClient
)} instances.");
64
public SpeechToTextClientBuilder Use(Func<
ISpeechToTextClient
,
ISpeechToTextClient
> clientFactory)
74
public SpeechToTextClientBuilder Use(Func<
ISpeechToTextClient
, IServiceProvider,
ISpeechToTextClient
> clientFactory)
SpeechToText\SpeechToTextClientBuilderServiceCollectionExtensions.cs (15)
11
/// <summary>Provides extension methods for registering <see cref="
ISpeechToTextClient
"/> with a <see cref="IServiceCollection"/>.</summary>
15
/// <summary>Registers a singleton <see cref="
ISpeechToTextClient
"/> in the <see cref="IServiceCollection"/>.</summary>
17
/// <param name="innerClient">The inner <see cref="
ISpeechToTextClient
"/> that represents the underlying backend.</param>
23
ISpeechToTextClient
innerClient,
27
/// <summary>Registers a singleton <see cref="
ISpeechToTextClient
"/> in the <see cref="IServiceCollection"/>.</summary>
29
/// <param name="innerClientFactory">A callback that produces the inner <see cref="
ISpeechToTextClient
"/> that represents the underlying backend.</param>
35
Func<IServiceProvider,
ISpeechToTextClient
> innerClientFactory,
42
serviceCollection.Add(new ServiceDescriptor(typeof(
ISpeechToTextClient
), builder.Build, lifetime));
46
/// <summary>Registers a keyed singleton <see cref="
ISpeechToTextClient
"/> in the <see cref="IServiceCollection"/>.</summary>
49
/// <param name="innerClient">The inner <see cref="
ISpeechToTextClient
"/> that represents the underlying backend.</param>
56
ISpeechToTextClient
innerClient,
60
/// <summary>Registers a keyed singleton <see cref="
ISpeechToTextClient
"/> in the <see cref="IServiceCollection"/>.</summary>
63
/// <param name="innerClientFactory">A callback that produces the inner <see cref="
ISpeechToTextClient
"/> that represents the underlying backend.</param>
70
Func<IServiceProvider,
ISpeechToTextClient
> innerClientFactory,
77
serviceCollection.Add(new ServiceDescriptor(typeof(
ISpeechToTextClient
), serviceKey, factory: (services, serviceKey) => builder.Build(services), lifetime));
SpeechToText\SpeechToTextClientBuilderSpeechToTextClientExtensions.cs (2)
9
/// <summary>Provides extension methods for working with <see cref="
ISpeechToTextClient
"/> in the context of <see cref="SpeechToTextClientBuilder"/>.</summary>
20
public static SpeechToTextClientBuilder AsBuilder(this
ISpeechToTextClient
innerClient)
Microsoft.Extensions.AI.Abstractions (25)
SpeechToText\DelegatingSpeechToTextClient.cs (5)
15
/// Provides an optional base class for an <see cref="
ISpeechToTextClient
"/> 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="
ISpeechToTextClient
"/>.
28
protected DelegatingSpeechToTextClient(
ISpeechToTextClient
innerClient)
40
/// <summary>Gets the inner <see cref="
ISpeechToTextClient
" />.</summary>
41
protected
ISpeechToTextClient
InnerClient { get; }
SpeechToText\ISpeechToTextClient.cs (6)
16
/// Unless otherwise specified, all members of <see cref="
ISpeechToTextClient
"/> are thread-safe for concurrent use.
17
/// It is expected that all implementations of <see cref="
ISpeechToTextClient
"/> support being used by multiple requests concurrently.
20
/// However, implementations of <see cref="
ISpeechToTextClient
"/> might mutate the arguments supplied to <see cref="GetTextAsync"/> and
23
/// <see cref="
ISpeechToTextClient
"/> instances are used which might employ such mutation. For example, the ConfigureOptions method be
51
/// <summary>Asks the <see cref="
ISpeechToTextClient
"/> for an object of the specified type <paramref name="serviceType"/>.</summary>
57
/// The purpose of this method is to allow for the retrieval of strongly typed services that might be provided by the <see cref="
ISpeechToTextClient
"/>,
SpeechToText\SpeechToTextClientExtensions.cs (6)
14
/// <summary>Extensions for <see cref="
ISpeechToTextClient
"/>.</summary>
18
/// <summary>Asks the <see cref="
ISpeechToTextClient
"/> for an object of type <typeparamref name="TService"/>.</summary>
24
/// The purpose of this method is to allow for the retrieval of strongly typed services that may be provided by the <see cref="
ISpeechToTextClient
"/>,
27
public static TService? GetService<TService>(this
ISpeechToTextClient
client, object? serviceKey = null)
41
this
ISpeechToTextClient
client,
63
this
ISpeechToTextClient
client,
SpeechToText\SpeechToTextClientMetadata.cs (1)
9
/// <summary>Provides metadata about an <see cref="
ISpeechToTextClient
"/>.</summary>
SpeechToText\SpeechToTextOptions.cs (6)
54
/// The underlying <see cref="
ISpeechToTextClient
" /> implementation may have its own representation of options.
55
/// When <see cref="
ISpeechToTextClient
.GetTextAsync" /> or <see cref="
ISpeechToTextClient
.GetStreamingTextAsync"/>
58
/// which concrete <see cref="
ISpeechToTextClient
" /> is being used and how it represents options, a new instance of that
59
/// implementation-specific options type may be returned by this callback, for the <see cref="
ISpeechToTextClient
" />
67
public Func<
ISpeechToTextClient
, object?>? RawRepresentationFactory { get; set; }
SpeechToText\SpeechToTextResponseUpdate.cs (1)
13
/// Represents a single streaming response chunk from an <see cref="
ISpeechToTextClient
"/>.
Microsoft.Extensions.AI.Abstractions.Tests (6)
SpeechToText\DelegatingSpeechToTextClientTests.cs (3)
127
var
client = delegating.GetService<
ISpeechToTextClient
>(expectedKey);
164
private sealed class NoOpDelegatingSpeechToTextClient(
ISpeechToTextClient
innerClient)
SpeechToText\SpeechToTextClientExtensionsTests.cs (2)
27
ISpeechToTextClient
? client = null;
41
ISpeechToTextClient
? client = null;
SpeechToText\SpeechToTextOptionsTests.cs (1)
38
Func<
ISpeechToTextClient
?, object?> rawRepresentationFactory = (c) => null;
Microsoft.Extensions.AI.Integration.Tests (2)
SpeechToTextClientIntegrationTests.cs (2)
18
private readonly
ISpeechToTextClient
? _client;
31
protected abstract
ISpeechToTextClient
? CreateClient();
Microsoft.Extensions.AI.OpenAI (4)
OpenAIClientExtensions.cs (3)
149
/// <summary>Gets an <see cref="
ISpeechToTextClient
"/> for use with this <see cref="AudioClient"/>.</summary>
151
/// <returns>An <see cref="
ISpeechToTextClient
"/> that can be used to transcribe audio via the <see cref="AudioClient"/>.</returns>
154
public static
ISpeechToTextClient
AsISpeechToTextClient(this AudioClient audioClient) =>
OpenAISpeechToTextClient.cs (1)
20
/// <summary>Represents an <see cref="
ISpeechToTextClient
"/> for an OpenAI <see cref="OpenAIClient"/> or <see cref="OpenAI.Audio.AudioClient"/>.</summary>
Microsoft.Extensions.AI.OpenAI.Tests (14)
OpenAISpeechToTextClientIntegrationTests.cs (1)
8
protected override
ISpeechToTextClient
? CreateClient()
OpenAISpeechToTextClientTests.cs (13)
36
ISpeechToTextClient
speechToTextClient = client.GetAudioClient(model).AsISpeechToTextClient();
47
ISpeechToTextClient
speechToTextClient = audioClient.AsISpeechToTextClient();
48
Assert.Same(speechToTextClient, speechToTextClient.GetService<
ISpeechToTextClient
>());
51
using
ISpeechToTextClient
pipeline = speechToTextClient
59
Assert.IsType<LoggingSpeechToTextClient>(pipeline.GetService<
ISpeechToTextClient
>());
84
using
ISpeechToTextClient
client = CreateSpeechToTextClient(httpClient, "gpt-4o-transcribe");
105
using
ISpeechToTextClient
client = CreateSpeechToTextClient(httpClient, "gpt-4o-transcribe");
119
using
ISpeechToTextClient
client = CreateSpeechToTextClient(httpClient, "gpt-4o-transcribe");
159
using
ISpeechToTextClient
client = CreateSpeechToTextClient(httpClient, "gpt-4o-transcribe");
194
using
ISpeechToTextClient
client = CreateSpeechToTextClient(httpClient, "gpt-4o-transcribe");
231
using
ISpeechToTextClient
client = CreateSpeechToTextClient(httpClient, "gpt-4o-transcribe");
268
using
ISpeechToTextClient
client = CreateSpeechToTextClient(httpClient, "gpt-4o-transcribe");
288
private static
ISpeechToTextClient
CreateSpeechToTextClient(HttpClient httpClient, string modelId) =>
Microsoft.Extensions.AI.Tests (51)
SpeechToText\ConfigureOptionsSpeechToTextClientTests.cs (2)
42
using
ISpeechToTextClient
innerClient = new TestSpeechToTextClient
59
using
var
client = innerClient
SpeechToText\LoggingSpeechToTextClientTests.cs (17)
32
Assert.Same(innerClient, innerClient.AsBuilder().UseLogging(NullLoggerFactory.Instance).Build().GetService(typeof(
ISpeechToTextClient
)));
57
using
ISpeechToTextClient
innerClient = new TestSpeechToTextClient
65
using
ISpeechToTextClient
client = innerClient
79
entry => Assert.True(entry.Message.Contains($"{nameof(
ISpeechToTextClient
.GetTextAsync)} invoked:") && entry.Message.Contains("\"speechLanguage\": \"pt\"")),
80
entry => Assert.True(entry.Message.Contains($"{nameof(
ISpeechToTextClient
.GetTextAsync)} completed:") && entry.Message.Contains("blue whale")));
85
entry => Assert.True(entry.Message.Contains($"{nameof(
ISpeechToTextClient
.GetTextAsync)} invoked.") && !entry.Message.Contains("\"speechLanguage\": \"pt\"")),
86
entry => Assert.True(entry.Message.Contains($"{nameof(
ISpeechToTextClient
.GetTextAsync)} completed.") && !entry.Message.Contains("blue whale")));
103
using
ISpeechToTextClient
innerClient = new TestSpeechToTextClient
115
using
ISpeechToTextClient
client = innerClient
132
entry => Assert.True(entry.Message.Contains($"{nameof(
ISpeechToTextClient
.GetStreamingTextAsync)} invoked:") && entry.Message.Contains("\"speechLanguage\": \"pt\"")),
133
entry => Assert.True(entry.Message.Contains($"{nameof(
ISpeechToTextClient
.GetStreamingTextAsync)} received update:") && entry.Message.Contains("blue")),
134
entry => Assert.True(entry.Message.Contains($"{nameof(
ISpeechToTextClient
.GetStreamingTextAsync)} received update:") && entry.Message.Contains("whale")),
135
entry => Assert.Contains($"{nameof(
ISpeechToTextClient
.GetStreamingTextAsync)} completed.", entry.Message));
140
entry => Assert.True(entry.Message.Contains($"{nameof(
ISpeechToTextClient
.GetStreamingTextAsync)} invoked.") && !entry.Message.Contains("speechLanguage")),
141
entry => Assert.True(entry.Message.Contains($"{nameof(
ISpeechToTextClient
.GetStreamingTextAsync)} received update.") && !entry.Message.Contains("blue")),
142
entry => Assert.True(entry.Message.Contains($"{nameof(
ISpeechToTextClient
.GetStreamingTextAsync)} received update.") && !entry.Message.Contains("whale")),
143
entry => Assert.Contains($"{nameof(
ISpeechToTextClient
.GetStreamingTextAsync)} completed.", entry.Message));
SpeechToText\OpenTelemetrySpeechToTextClientTests.cs (1)
84
using
var
client = innerClient
SpeechToText\SpeechToTextClientDependencyInjectionPatterns.cs (31)
26
var
instance1 = scope1.ServiceProvider.GetRequiredService<
ISpeechToTextClient
>();
27
var
instance1Copy = scope1.ServiceProvider.GetRequiredService<
ISpeechToTextClient
>();
28
var
instance2 = scope2.ServiceProvider.GetRequiredService<
ISpeechToTextClient
>();
50
var
instance1 = scope1.ServiceProvider.GetRequiredService<
ISpeechToTextClient
>();
51
var
instance1Copy = scope1.ServiceProvider.GetRequiredService<
ISpeechToTextClient
>();
52
var
instance2 = scope2.ServiceProvider.GetRequiredService<
ISpeechToTextClient
>();
73
Assert.Null(services.GetService<
ISpeechToTextClient
>());
75
var
instance1 = scope1.ServiceProvider.GetRequiredKeyedService<
ISpeechToTextClient
>("mykey");
76
var
instance1Copy = scope1.ServiceProvider.GetRequiredKeyedService<
ISpeechToTextClient
>("mykey");
77
var
instance2 = scope2.ServiceProvider.GetRequiredKeyedService<
ISpeechToTextClient
>("mykey");
99
Assert.Null(services.GetService<
ISpeechToTextClient
>());
101
var
instance1 = scope1.ServiceProvider.GetRequiredKeyedService<
ISpeechToTextClient
>("mykey");
102
var
instance1Copy = scope1.ServiceProvider.GetRequiredKeyedService<
ISpeechToTextClient
>("mykey");
103
var
instance2 = scope2.ServiceProvider.GetRequiredKeyedService<
ISpeechToTextClient
>("mykey");
126
Assert.Equal(typeof(
ISpeechToTextClient
), sd.ServiceType);
148
Assert.Equal(typeof(
ISpeechToTextClient
), sd.ServiceType);
164
Assert.Equal(typeof(
ISpeechToTextClient
), sd.ServiceType);
173
public class SingletonMiddleware(
ISpeechToTextClient
inner, IServiceProvider services) : DelegatingSpeechToTextClient(inner)
175
public new
ISpeechToTextClient
InnerClient => base.InnerClient;