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
baseUrlstringServer root, for example
http://127.0.0.1:8080.httpClientHttpClientOptional transport; see the Uri constructor overload.
apiKeystringOptional 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
baseUrlUriServer root, for example
http://127.0.0.1:8080.httpClientHttpClientOptional 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).
apiKeystringOptional 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
ApiKey
Bearer token sent on every request, when set.
public string? ApiKey { get; }
Property Value
Recipes
Multi-model recipes.
public RecipeClient Recipes { get; }
Property Value
Speech
Speech synthesis, streaming speech, and live speech-to-speech.
public SpeechClient Speech { get; }
Property Value
Tasks
Generic framework tasks: run, stream, batch.
public TaskClient Tasks { get; }
Property Value
Transcriptions
Transcription, details, streaming, live capture, and native batches.
public TranscriptionClient Transcriptions { get; }
Property Value
Methods
GetHealthAsync(CancellationToken)
Server readiness from GET /health.
public Task<AudioCppHealth> GetHealthAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenCancellation 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
includeParamsboolAdd each model's declared request options (
include_params=true).includeSessionOptionsboolEcho each model's configured session options (
include_session_options=true).cancellationTokenCancellationTokenCancellation token.
Returns
- Task<IReadOnlyList<AudioCppModel>>
The model list (
dataarray).
Exceptions
- AudioCppException
The request failed.
ListRecipesAsync(CancellationToken)
List available recipes from GET /v1/recipes.
public Task<IReadOnlyList<RecipeEntry>> ListRecipesAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<IReadOnlyList<RecipeEntry>>
The recipe list (
dataarray).
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
modelstringModel id to scope the lookup to.
cancellationTokenCancellationTokenCancellation 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
requestModelLoadRequestThe load request (validated before sending).
cancellationTokenCancellationTokenCancellation 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
cancellationTokenCancellationTokenCancellation 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
modelIdsIEnumerable<string>Model ids to unload.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<UnloadModelsResult>
The unload report (unloaded and not-found ids).
Exceptions
- AudioCppException
The request failed.