Class: Revox::Resources::Voices

Inherits:
Object
  • Object
show all
Defined in:
lib/revox/resources/voices.rb,
sig/revox/resources/voices.rbs

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Voices

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Voices.

Parameters:



138
139
140
# File 'lib/revox/resources/voices.rb', line 138

def initialize(client:)
  @client = client
end

Instance Method Details

#clone_(audio:, content_type:, language:, name:, request_options: {}) ⇒ Revox::Models::VoiceCloneResponse

Clone a voice from an audio recording. Send audio as a base64-encoded string. The cloned voice will be available in GET /voices.

Parameters:

Returns:

See Also:



89
90
91
92
93
94
95
96
97
98
# File 'lib/revox/resources/voices.rb', line 89

def clone_(params)
  parsed, options = Revox::VoiceCloneParams.dump_request(params)
  @client.request(
    method: :post,
    path: "voices/clone",
    body: parsed,
    model: Revox::Models::VoiceCloneResponse,
    options: options
  )
end

#delete(id, request_options: {}) ⇒ Revox::Models::VoiceDeleteResponse

Delete a cloned voice. Only cloned voices can be deleted. Returns 409 if the voice is in use by an assistant.

Parameters:

  • id (String)

    The cloned voice ID to delete.

  • request_options (Revox::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



62
63
64
65
66
67
68
69
# File 'lib/revox/resources/voices.rb', line 62

def delete(id, params = {})
  @client.request(
    method: :delete,
    path: ["voices/%1$s", id],
    model: Revox::Models::VoiceDeleteResponse,
    options: params[:request_options]
  )
end

#list(request_options: {}) ⇒ Revox::Models::VoiceListResponse

Retrieve all voices available for AI calls, including preset voices from Cartesia/ElevenLabs and your organization's cloned voices.

Parameters:

Returns:

See Also:



41
42
43
44
45
46
47
48
# File 'lib/revox/resources/voices.rb', line 41

def list(params = {})
  @client.request(
    method: :get,
    path: "voices",
    model: Revox::Models::VoiceListResponse,
    options: params[:request_options]
  )
end

#preview(provider:, voice_id:, model: nil, speed: nil, text: nil, volume: nil, request_options: {}) ⇒ nil

Some parameter documentations has been truncated, see Models::VoicePreviewParams for more details.

Generate a short audio preview for a given voice.

Parameters:

  • provider (Symbol, Revox::Models::VoicePreviewParams::Provider)

    The provider to use for the preview.

  • voice_id (String)

    The voice ID to generate a preview for.

  • model (Symbol, Revox::Models::VoicePreviewParams::Model)

    Cartesia model for the preview. Defaults to sonic-3. Ignored for other providers

  • speed (Float)

    Speed for preview. Cartesia 0.6–1.5, ElevenLabs 0.7–1.2. Default 1.0.

  • text (String)

    Custom text for the preview. If omitted, a short default is used.

  • volume (Float)

    Volume for Cartesia preview (0.5–2.0). Ignored for other providers.

  • request_options (Revox::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

  • (nil)

See Also:



124
125
126
127
128
129
130
131
132
133
# File 'lib/revox/resources/voices.rb', line 124

def preview(params)
  parsed, options = Revox::VoicePreviewParams.dump_request(params)
  @client.request(
    method: :post,
    path: "voices/preview",
    body: parsed,
    model: NilClass,
    options: options
  )
end

#retrieve(id, provider:, request_options: {}) ⇒ Revox::Models::VoiceRetrieveResponse

Retrieve details for a single voice by its unique ID and provider.

Parameters:

Returns:

See Also:



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/revox/resources/voices.rb', line 19

def retrieve(id, params)
  parsed, options = Revox::VoiceRetrieveParams.dump_request(params)
  query = Revox::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["voices/%1$s", id],
    query: query,
    model: Revox::Models::VoiceRetrieveResponse,
    options: options
  )
end