CasCap.Api.Azure.CognitiveServices
2.0.0
Prefix Reserved
See the version list below for details.
dotnet add package CasCap.Api.Azure.CognitiveServices --version 2.0.0
NuGet\Install-Package CasCap.Api.Azure.CognitiveServices -Version 2.0.0
<PackageReference Include="CasCap.Api.Azure.CognitiveServices" Version="2.0.0" />
<PackageVersion Include="CasCap.Api.Azure.CognitiveServices" Version="2.0.0" />
<PackageReference Include="CasCap.Api.Azure.CognitiveServices" />
paket add CasCap.Api.Azure.CognitiveServices --version 2.0.0
#r "nuget: CasCap.Api.Azure.CognitiveServices, 2.0.0"
#:package CasCap.Api.Azure.CognitiveServices@2.0.0
#addin nuget:?package=CasCap.Api.Azure.CognitiveServices&version=2.0.0
#tool nuget:?package=CasCap.Api.Azure.CognitiveServices&version=2.0.0
CasCap.Api.Azure.CognitiveServices
Azure Cognitive Services helpers for .NET applications that synthesize audio, transcribe recordings
or extract bounded PDF layout Markdown.
SpeechService implements
ISpeechService
using the Azure Speech SDK and fast transcription client.
Installation
Targets net8.0, net9.0 and net10.0.
dotnet add package CasCap.Api.Azure.CognitiveServices
Usage
Provide a Speech resource endpoint and an Azure TokenCredential with resource access:
using CasCap.Services;
var speech = new SpeechService(speechEndpoint, credential);
byte[]? audio = await speech.SynthesizeAsync(
"Hello world", voice: "en-GB-SoniaNeural", cancellationToken: cancellationToken);
SynthesizeAsync returns Ogg Opus bytes (Ogg48Khz16BitMonoOpus), or null if synthesis produces no
audio. Omit voice to use the SDK default. The cancellation parameter is not forwarded to the
underlying synthesis call, so do not assume it cancels speech generation.
For a recording, prefer the whole-file fast transcription path:
using var recording = File.OpenRead(audioPath);
string? transcript = await speech.TranscribeAsync(
recording, locales: ["en-GB"], cancellationToken: cancellationToken);
TranscribeAsync requires the endpoint-and-credential constructor. A subscription-key constructor
also exists (new SpeechService(subscriptionKey, region)), with region defaulting to westeurope,
but it cannot be used for fast transcription. The wrapper returns the first combined phrase's text,
or null for empty text; it does not expose the service's full phrase/channel metadata.
CreateWAV(text, path) writes a WAV file. RecognizeFromWAV(path) and
RecognizeFromMicrophone() recognize a single utterance, not an entire recording; microphone
recognition also requires a working audio input device.
Speech logging never includes synthesized text or recognized transcripts, only their lengths at
Debug. A canceled speech operation logs once: an Error with the service error code and details when
the cancellation reason is an error, otherwise a Warning with the reason. An unrecognized utterance
logs at Debug and returns null.
Document Layout
The package includes
AzDocumentLayoutClient,
with DocumentLayoutOptions
and DocumentLayoutPollResult.
Supply a caller-owned HttpClient whose BaseAddress is a canonical, credential-free HTTPS root
ending in /, on port 443. Authentication belongs in its handler. Disable redirects, POST retries,
hedging and authentication replay in the handler pipeline. The transport makes one SendAsync call
per public method; it cannot override replay or logging added by a caller's handler.
using CasCap.Models;
using CasCap.Services;
// httpClient is provided by the host, with authentication and no mutation replay.
var layout = new AzDocumentLayoutClient(httpClient, new DocumentLayoutOptions());
Uri receipt = await layout.SubmitAsync(pdfBytes, [1, 2], cancellationToken);
// Persist the receipt before scheduling subsequent work.
DocumentLayoutPollResult observation =
await layout.GetResultAsync(receipt, [1, 2], cancellationToken);
SubmitAsync sends exactly one JSON base64Source POST for prebuilt-layout, API 2024-11-30,
Markdown and UTF-16 code-unit indexing. Only HTTP 202 with one same-authority operation receipt is
accepted. The receipt must contain the exact model/result/GUID path and API-version query.
Submission errors, timeouts and cancellation may leave an unknown remote outcome; do not blindly
resubmit. Retain that ambiguity in the caller's durable state.
GetResultAsync performs one GET against a saved receipt, even on a newly constructed client.
It never submits, sleeps or loops. notStarted and running normalize to Running; failed and
canceled normalize to Failed. Only Succeeded includes complete Markdown and page projections.
The caller owns scheduling and any GET retry budget. RetryAfter is nullable; delta values are
preserved, and absolute dates use the configured clock and clamp past dates to zero.
Successful results require exact version/model/format metadata and the unique, exact requested page
set. Spans are bounded UTF-16 ranges that cannot split surrogate pairs, duplicate or overlap within
or across pages. Page fragments are concatenated in offset order without inserting text. Empty
Markdown and empty page-span arrays are permitted for blank pages. Malformed JSON, duplicate JSON
properties, unknown statuses and invalid receipts/results raise redacted HttpRequestException;
HTTP failures retain the status code but not the response body or transport exception details.
Caller input errors use argument exceptions; requested cancellation remains cancellation.
No PDF content, authorization headers, operation identifiers or service error bodies are logged by this transport. Host HTTP diagnostics must independently redact sensitive data. It does not configure credentials, deadlines, service quotas, quality policy or semantic acceptance of extracted text.
Service Requirements
Use an Azure Speech resource, a supported region and audio format, and the native prerequisites for
the Speech SDK on your platform. With Microsoft Entra authentication, assign the caller the
Cognitive Services Speech User role as appropriate.
Fast transcription availability, pricing tiers and file limits are controlled by Azure, not this wrapper. Check the fast transcription guide and Speech SDK installation requirements. Service guidance checked 20 October 2026; no live service call is implied.
Configuration Examples
CognitiveServicesConfig exposes a required subscription key under
CasCap:CognitiveServicesConfig. There is no registration helper that binds it or constructs
SpeechService; the consuming application owns both steps.
{
"CasCap": {
"CognitiveServicesConfig": {
"SubscriptionKey": "your-subscription-key"
}
}
}
Store the actual key in user secrets or a secret-backed configuration provider. Endpoint, credential and region are constructor inputs, not properties of this configuration model.
Layout options are direct constructor inputs, not part of CognitiveServicesConfig. Defaults and
maximum supported bounds are 25 MiB PDF bytes, 16 MiB response bytes, and 2000 selected pages/page
numbers. Each configured bound must be positive; callers can lower it. PDF signature and byte limits
are checked before submission, and result bytes are limited while streaming, including when no
Content-Length is present.
var defaults = new DocumentLayoutOptions();
var bounded = new DocumentLayoutOptions
{
MaximumPdfBytes = 25 * 1024 * 1024,
MaximumResponseBytes = 16 * 1024 * 1024,
MaximumPages = 2000,
TimeProvider = TimeProvider.System,
};
Pass a controlled TimeProvider for deterministic absolute Retry-After interpretation. Supply a
cancellation token covering the complete response-body read; the host owns total deadlines.
Documentation
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. 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. |
-
net10.0
- Azure.AI.Speech.Transcription (>= 1.0.0)
- CasCap.Common.Extensions (>= 5.1.0)
- CasCap.Common.Logging (>= 5.1.0)
- Microsoft.CognitiveServices.Speech (>= 1.53.0)
-
net8.0
- Azure.AI.Speech.Transcription (>= 1.0.0)
- CasCap.Common.Extensions (>= 5.1.0)
- CasCap.Common.Logging (>= 5.1.0)
- Microsoft.CognitiveServices.Speech (>= 1.53.0)
-
net9.0
- Azure.AI.Speech.Transcription (>= 1.0.0)
- CasCap.Common.Extensions (>= 5.1.0)
- CasCap.Common.Logging (>= 5.1.0)
- Microsoft.CognitiveServices.Speech (>= 1.53.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on CasCap.Api.Azure.CognitiveServices:
| Package | Downloads |
|---|---|
|
CasCap.Api.Voice
Provider-neutral speech-to-text and text-to-speech components for .NET applications. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.1.0 | 328 | 11/14/2026 |
| 2.0.0 | 401 | 11/5/2026 |
| 1.8.0 | 232 | 11/1/2026 |
| 1.7.1 | 285 | 10/24/2026 |
| 1.7.0 | 239 | 10/21/2026 |
| 1.6.4 | 214 | 10/4/2026 |
| 1.6.3 | 240 | 9/25/2026 |
| 1.6.2 | 219 | 9/23/2026 |
| 1.6.1 | 146 | 9/21/2026 |
| 1.6.0 | 176 | 9/19/2026 |
| 1.5.5 | 143 | 9/11/2026 |
| 1.5.4 | 127 | 9/1/2026 |
| 1.5.3 | 147 | 8/18/2026 |
| 1.5.2 | 153 | 7/15/2026 |
| 1.5.1 | 167 | 6/26/2026 |
| 1.5.0 | 150 | 6/12/2026 |
| 1.4.13 | 148 | 6/10/2026 |
| 1.4.12 | 271 | 5/27/2026 |
| 1.4.11 | 168 | 5/26/2026 |
| 1.4.10 | 201 | 5/21/2026 |