Table of Contents

Class VoicesClient

Namespace
GenerativeAI.Clients
Assembly
GenerativeAI.dll

A client for the Voices API (/voices): design voices from a prompt, remix an existing voice, replicate a voice from recorded audio, and list custom and prebuilt voices for text-to-speech. Follows python-genai's client.voices.

public class VoicesClient : AgentApiClientBase
Inheritance
VoicesClient
Inherited Members
Extension Methods

Constructors

VoicesClient(IPlatformAdapter, HttpClient?, ILogger?)

Initializes a new instance of the VoicesClient class.

public VoicesClient(IPlatformAdapter platform, HttpClient? httpClient = null, ILogger? logger = null)

Parameters

platform IPlatformAdapter

The platform adapter (Google AI or Vertex AI).

httpClient HttpClient

Optional HTTP client.

logger ILogger

Optional logger.

Methods

CreateAsync(CreateVoiceRequest, CancellationToken)

Creates a voice (POST /voices).

public Task<Voice> CreateAsync(CreateVoiceRequest request, CancellationToken cancellationToken = default)

Parameters

request CreateVoiceRequest

The request.

cancellationToken CancellationToken

A cancellation token.

Returns

Task<Voice>

The created voice.

CreateAsync(Voice, bool?, CancellationToken)

Creates a voice (POST /voices).

public Task<Voice> CreateAsync(Voice voice, bool? store = null, CancellationToken cancellationToken = default)

Parameters

voice Voice

The voice to create.

store bool?

Whether to store the voice for reuse.

cancellationToken CancellationToken

A cancellation token.

Returns

Task<Voice>

The created voice.

DeleteAsync(string, CancellationToken)

Deletes a custom voice (DELETE /voices/{id}).

public Task<DeleteVoiceResponse> DeleteAsync(string id, CancellationToken cancellationToken = default)

Parameters

id string

The voice ID.

cancellationToken CancellationToken

A cancellation token.

Returns

Task<DeleteVoiceResponse>

The (empty) delete response.

DesignAsync(string, string?, bool?, CancellationToken)

Designs a voice from a text description (a prompted voice).

public Task<Voice> DesignAsync(string prompt, string? displayName = null, bool? store = null, CancellationToken cancellationToken = default)

Parameters

prompt string

The description of the voice.

displayName string

Optional display name.

store bool?

Whether to store the voice for reuse.

cancellationToken CancellationToken

A cancellation token.

Returns

Task<Voice>

The designed voice.

GetAsync(string, CancellationToken)

Gets a voice (GET /voices/{id}).

public Task<Voice> GetAsync(string id, CancellationToken cancellationToken = default)

Parameters

id string

The voice ID (a voices/ prefix is accepted).

cancellationToken CancellationToken

A cancellation token.

Returns

Task<Voice>

The voice.

ListAllAsync(ListVoicesOptions?, int?, CancellationToken)

Lists all voices matching options, following page tokens.

public IAsyncEnumerable<Voice> ListAllAsync(ListVoicesOptions? options = null, int? pageSize = null, CancellationToken cancellationToken = default)

Parameters

options ListVoicesOptions

Optional filters.

pageSize int?

The page size.

cancellationToken CancellationToken

A cancellation token.

Returns

IAsyncEnumerable<Voice>

The voices.

ListAsync(ListVoicesOptions?, int?, string?, CancellationToken)

Lists one page of voices (GET /voices): custom voices (newest first) followed by prebuilt voices.

public Task<ListVoicesResponse> ListAsync(ListVoicesOptions? options = null, int? pageSize = null, string? pageToken = null, CancellationToken cancellationToken = default)

Parameters

options ListVoicesOptions

Optional filters.

pageSize int?

The maximum number of voices per page (server default 50, max 1000).

pageToken string

The page token of a previous call (filters must match).

cancellationToken CancellationToken

A cancellation token.

Returns

Task<ListVoicesResponse>

The page.

RemixAsync(string, string, string?, bool?, CancellationToken)

Remixes an existing voice according to instructions (a prompted voice with a base voice).

public Task<Voice> RemixAsync(string baseVoice, string instructions, string? displayName = null, bool? store = null, CancellationToken cancellationToken = default)

Parameters

baseVoice string

The voice to remix.

instructions string

How to change the voice.

displayName string

Optional display name.

store bool?

Whether to store the voice for reuse.

cancellationToken CancellationToken

A cancellation token.

Returns

Task<Voice>

The remixed voice.

ReplicateAsync(VoiceAudioData, VoiceAudioData, string?, bool?, CancellationToken)

Replicates a voice from recorded audio (a replicated voice).

public Task<Voice> ReplicateAsync(VoiceAudioData sourceAudio, VoiceAudioData consentAudio, string? displayName = null, bool? store = null, CancellationToken cancellationToken = default)

Parameters

sourceAudio VoiceAudioData

Audio of the voice to replicate.

consentAudio VoiceAudioData

Audio of the speaker consenting to the replication.

displayName string

Optional display name.

store bool?

Whether to store the voice for reuse.

cancellationToken CancellationToken

A cancellation token.

Returns

Task<Voice>

The replicated voice.