CasCap.Api.Voice.Testing
0.3.0
Prefix Reserved
dotnet add package CasCap.Api.Voice.Testing --version 0.3.0
NuGet\Install-Package CasCap.Api.Voice.Testing -Version 0.3.0
<PackageReference Include="CasCap.Api.Voice.Testing" Version="0.3.0" />
<PackageVersion Include="CasCap.Api.Voice.Testing" Version="0.3.0" />
<PackageReference Include="CasCap.Api.Voice.Testing" />
paket add CasCap.Api.Voice.Testing --version 0.3.0
#r "nuget: CasCap.Api.Voice.Testing, 0.3.0"
#:package CasCap.Api.Voice.Testing@0.3.0
#addin nuget:?package=CasCap.Api.Voice.Testing&version=0.3.0
#tool nuget:?package=CasCap.Api.Voice.Testing&version=0.3.0
CasCap.Api.Voice.Testing
Canned speech-to-text and text-to-speech clients for testing code built on CasCap.Api.Voice
without a speech backend.
Installation
dotnet package add CasCap.Api.Voice.Testing
Reference it from test projects only. Its only direct package dependency is the core Voice package; see the package dependency graph.
Test Clients
The Voice pipelines depend on the Microsoft.Extensions.AI
ISpeechToTextClient
and ITextToSpeechClient
contracts. These fakes stand in for a real provider, so a consumer can
exercise transcription, synthesis and its own orchestration deterministically. There is no
network, audio tooling or credential involved.
Target frameworks: net10.0, net11.0
Public Surface
All types live in the CasCap.Fakes namespace.
| Type | Behaviour |
|---|---|
FakeSpeechToTextClient |
Returns Transcript. It counts Requests, fails with Failure when set, and waits on Gate when set, so a test can observe work that is still in flight. |
FakeTextToSpeechClient |
Returns Audio with MediaType (Ogg Opus by default). It counts Requests, records LastText, and fails with Failure when set. |
The default synthesis bytes are only the four-byte OggS signature, not playable audio. Supply
appropriate synthetic content when the consumer validates or decodes its result.
Usage
Replace the provider client before the Voice pipeline is resolved:
using CasCap.Fakes;
using Microsoft.Extensions.AI;
using Microsoft.Extensions.DependencyInjection;
#pragma warning disable MEAI001
var stt = new FakeSpeechToTextClient { Transcript = "synthetic transcript" };
var tts = new FakeTextToSpeechClient();
services.AddSingleton<ISpeechToTextClient>(stt);
services.AddSingleton<ITextToSpeechClient>(tts);
services.AddSpeechToText();
services.AddTextToSpeech();
#pragma warning restore MEAI001
services is the test host's IServiceCollection. The provider interfaces are experimental upstream,
so the example scopes that compiler diagnostic to the registration code.
AddSpeechToText and AddTextToSpeech register their provider clients with TryAdd. A fake
registered before them therefore takes precedence, and so does a later plain AddSingleton.
Replacing a provider does not bypass media validation or synthesis policy: supply valid audio and
enable a reply mode when testing the full pipelines.
See the core package usage for the application-facing contracts.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. net11.0 is compatible. |
-
net10.0
- CasCap.Api.Voice (>= 0.3.0)
-
net11.0
- CasCap.Api.Voice (>= 0.3.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.