Skip to content
Tracon

SpeechDialogueCapabilities

Namespace Tracon · Assembly Tracon.Abstractions.dll

The limits of one dialogue request, as the provider states them.

public sealed record SpeechDialogueCapabilities : IEquatable<SpeechDialogueCapabilities>
Inheritance
object ← SpeechDialogueCapabilities
Implements
IEquatable<SpeechDialogueCapabilities>
Inherited Members
object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

The caller plans its requests from these values: a request over a limit is refused, never split or truncated.

public SpeechDialogueCapabilities()

Gets the most characters one request can carry, summed over its turns.

public required int MaxCharactersPerRequest { get; init; }

int

Gets the most distinct voices one request can use.

public required int MaxVoices { get; init; }

int

Gets whether the provider reports each turn’s time range when the request sets IncludeTimestamps.

public bool SupportsSegmentTimestamps { get; init; }

bool

Check(SpeechDialogueRequest, string, string?)

Section titled “ Check(SpeechDialogueRequest, string, string?)”

Checks a dialogue request against these limits.

public int Check(SpeechDialogueRequest request, string providerName, string? characterLimitSetting = null)

request SpeechDialogueRequest

The request.

providerName string

The provider name; the messages name it.

characterLimitSetting string?

The name of the setting that sets SpeechDialogueCapabilities.MaxCharactersPerRequest, or null when no setting does. The message names it when it is given.

int

The characters of all turns: the estimate when the provider reports no count.

The rule every dialogue implementation applies before it calls its service: a request over a limit is the caller’s to split, never the implementation’s to cut. An implementation that calls this method refuses the same requests the built-in ElevenLabs client refuses, in the same words.

A voice counts once however many turns use it, and the comparison is ordinal.

A dialogue implementation of your own refuses a request over its limits before it calls its service:

internal sealed class ContosoDialogueSynthesizer : ISpeechDialogueSynthesizer
{
public string ProviderName => "contoso";
public SpeechDialogueCapabilities DialogueCapabilities { get; } = new()
{
MaxVoices = 2,
MaxCharactersPerRequest = 1000,
};
public ValueTask<SpeechDialogueAudio> SynthesizeDialogueAsync(
SpeechDialogueRequest request,
CancellationToken cancellationToken = default)
{
// Throws a TraconException that names the limit; the service is not called.
var characters = DialogueCapabilities.Check(request, ProviderName);
// ... send the turns to the service and read the audio it answers ...
var audio = new SpeechAudio
{
Data = Array.Empty<byte>(),
MediaType = "audio/wav",
CharactersBilled = characters,
UsageSource = SpeechUsageSource.Estimated,
};
return ValueTask.FromResult(new SpeechDialogueAudio { Audio = audio });
}
}

ArgumentNullException

request is null.

ArgumentException

providerName is empty.

TraconException

The request has no turn, a turn is missing or has no text or no voice, the turns use more than SpeechDialogueCapabilities.MaxVoices voices, or they carry more than SpeechDialogueCapabilities.MaxCharactersPerRequest characters. The message never carries a turn’s text.

public override bool Equals(object? obj)

obj object?

bool

public bool Equals(SpeechDialogueCapabilities? other)

other SpeechDialogueCapabilities?

bool

public override int GetHashCode()

int

public override string ToString()

string

operator ==(SpeechDialogueCapabilities?, SpeechDialogueCapabilities?)

Section titled “ operator ==(SpeechDialogueCapabilities?, SpeechDialogueCapabilities?)”
public static bool operator ==(SpeechDialogueCapabilities? left, SpeechDialogueCapabilities? right)

left SpeechDialogueCapabilities?

right SpeechDialogueCapabilities?

bool

operator !=(SpeechDialogueCapabilities?, SpeechDialogueCapabilities?)

Section titled “ operator !=(SpeechDialogueCapabilities?, SpeechDialogueCapabilities?)”
public static bool operator !=(SpeechDialogueCapabilities? left, SpeechDialogueCapabilities? right)

left SpeechDialogueCapabilities?

right SpeechDialogueCapabilities?

bool