Skip to content

ISpeechSynthesizer

Namespace AgentPrism · Assembly AgentPrism.Abstractions.dll

A provider that generates speech from text.

public interface ISpeechSynthesizer

ElevenLabs is an implementation, not a dependency. A consumer wanting another provider registers their own implementation; tools know only this contract.

The contract lives HERE, not in AgentPrism.Voice: the HTTP layer (AgentPrism.AspNetCore) sees these types while serving the voice endpoints, but it CANNOT reference AgentPrism.Voice (the package direction rule). The same pattern was applied to the MCP abstractions —.

The maximum number of characters accepted in a single ISpeechSynthesizer.SynthesizeAsync call.

int MaxCharactersPerRequest { get; }

int

The tool call (speak) AND the direct HTTP operator endpoint (POST /api/voice/speak) read the SAME value — the limit is applied consistently across both paths.

The provider name. Used in cost records and health checks.

string ProviderName { get; }

string

Lists the available voices.

ValueTask<IReadOnlyList<VoiceDescriptor>> ListVoicesAsync(CancellationToken cancellationToken = default)

cancellationToken CancellationToken

The cancellation token.

ValueTask<IReadOnlyList<VoiceDescriptor>>

The voices, ordered by name.

SynthesizeAsync(SpeechRequest, CancellationToken)

Section titled “ SynthesizeAsync(SpeechRequest, CancellationToken)”

Synthesizes speech from a text.

ValueTask<SpeechAudio> SynthesizeAsync(SpeechRequest request, CancellationToken cancellationToken = default)

request SpeechRequest

The request.

cancellationToken CancellationToken

The cancellation token.

ValueTask<SpeechAudio>

The generated audio.

SynthesizeStreamingAsync(SpeechRequest, CancellationToken)

Section titled “ SynthesizeStreamingAsync(SpeechRequest, CancellationToken)”

Synthesizes speech from a text and streams the audio piece by piece.

IAsyncEnumerable<ReadOnlyMemory<byte>> SynthesizeStreamingAsync(SpeechRequest request, CancellationToken cancellationToken = default)

request SpeechRequest

The request.

cancellationToken CancellationToken

The cancellation token.

IAsyncEnumerable<ReadOnlyMemory<byte>>

The audio chunks.

The streaming path is for low latency, and the voice layer uses it. The signature is defined now: adding a member to an interface later is a breaking change for consumers implementing that interface.

Streamed audio is not stored as an attachment. The billed quantity is unknown until the stream ends, and the chunks are not a valid file on their own; the speak tool uses the non-streaming path for this reason.