Table of Contents

Class AudioCppClient

Namespace
Mabs.AudioCpp
Assembly
AudioCpp.dll

Client for the audio.cpp server protocol. One instance maps to one server base URL and is thread-safe; share it. The per-area sub-clients (Speech, Transcriptions, Alignments, Tasks, Recipes) carry the endpoint groups; readiness, model, voice and unload routes sit directly on this type.

public sealed class AudioCppClient
Inheritance
AudioCppClient
Inherited Members

Constructors

AudioCppClient(string, HttpClient?, string?)

Creates a client from a base URL string.

public AudioCppClient(string baseUrl, HttpClient? httpClient = null, string? apiKey = null)

Parameters

baseUrl string

Server root, for example http://127.0.0.1:8080.

httpClient HttpClient

Optional transport; see the Uri constructor overload.

apiKey string

Optional bearer token sent on every request.

AudioCppClient(Uri, HttpClient?, string?)

Creates a client for the server at baseUrl.

public AudioCppClient(Uri baseUrl, HttpClient? httpClient = null, string? apiKey = null)

Parameters

baseUrl Uri

Server root, for example http://127.0.0.1:8080.

httpClient HttpClient

Optional transport. When omitted, a default HttpClient is created; pass your own to control proxies, timeouts or TLS. For the live routes it must be backed by a handler with full-duplex HTTP/1.1 support (the default handler on .NET Core and .NET Framework's WinHttpClient qualify; browser/WASM handlers do not).

apiKey string

Optional bearer token sent as Authorization: Bearer <key> on every request. The audio.cpp server ignores it today; frontends in front of it may require it.

Properties

Alignments

Forced alignment of known transcripts.

public AlignmentClient Alignments { get; }

Property Value

AlignmentClient

ApiKey

Bearer token sent on every request, when set.

public string? ApiKey { get; }

Property Value

string

Recipes

Multi-model recipes.

public RecipeClient Recipes { get; }

Property Value

RecipeClient

Speech

Speech synthesis, streaming speech, and live speech-to-speech.

public SpeechClient Speech { get; }

Property Value

SpeechClient

Tasks

Generic framework tasks: run, stream, batch.

public TaskClient Tasks { get; }

Property Value

TaskClient

Transcriptions

Transcription, details, streaming, live capture, and native batches.

public TranscriptionClient Transcriptions { get; }

Property Value

TranscriptionClient

Methods

GetHealthAsync(CancellationToken)

Server readiness from GET /health.

public Task<AudioCppHealth> GetHealthAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Cancellation token.

Returns

Task<AudioCppHealth>

The health report.

Exceptions

AudioCppException

The request failed.

ListModelsAsync(bool, bool, CancellationToken)

Configured models from GET /v1/models.

public Task<IReadOnlyList<AudioCppModel>> ListModelsAsync(bool includeParams = false, bool includeSessionOptions = false, CancellationToken cancellationToken = default)

Parameters

includeParams bool

Add each model's declared request options (include_params=true).

includeSessionOptions bool

Echo each model's configured session options (include_session_options=true).

cancellationToken CancellationToken

Cancellation token.

Returns

Task<IReadOnlyList<AudioCppModel>>

The model list (data array).

Exceptions

AudioCppException

The request failed.

ListRecipesAsync(CancellationToken)

List available recipes from GET /v1/recipes.

public Task<IReadOnlyList<RecipeEntry>> ListRecipesAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Cancellation token.

Returns

Task<IReadOnlyList<RecipeEntry>>

The recipe list (data array).

Exceptions

AudioCppException

The request failed.

ListVoicesAsync(string?, CancellationToken)

Discoverable voice names from GET /v1/audio/voices: cached voice ids, configured preset names, and shared voice-dir WAV basenames. Pass model when several models are configured.

public Task<IReadOnlyList<string>> ListVoicesAsync(string? model = null, CancellationToken cancellationToken = default)

Parameters

model string

Model id to scope the lookup to.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<IReadOnlyList<string>>

The voice names the server reports.

Exceptions

AudioCppException

The request failed.

LoadModelAsync(ModelLoadRequest, CancellationToken)

Dynamically load a model through POST /v1/models/load. Only servers built with native model management and started with --ui-management serve this route (otherwise HTTP 403, error type forbidden).

public Task<ModelLoadResult> LoadModelAsync(ModelLoadRequest request, CancellationToken cancellationToken = default)

Parameters

request ModelLoadRequest

The load request (validated before sending).

cancellationToken CancellationToken

Cancellation token.

Returns

Task<ModelLoadResult>

The load report.

Exceptions

AudioCppException

The request failed.

UnloadAllModelsAsync(CancellationToken)

Unload every currently loaded model.

public Task<UnloadModelsResult> UnloadAllModelsAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Cancellation token.

Returns

Task<UnloadModelsResult>

The unload report.

Exceptions

AudioCppException

The request failed.

UnloadModelsAsync(IEnumerable<string>, CancellationToken)

Unload specific models from memory; unknown ids are reported, not an error.

public Task<UnloadModelsResult> UnloadModelsAsync(IEnumerable<string> modelIds, CancellationToken cancellationToken = default)

Parameters

modelIds IEnumerable<string>

Model ids to unload.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<UnloadModelsResult>

The unload report (unloaded and not-found ids).

Exceptions

AudioCppException

The request failed.