Class: Telnyx::Resources::VoiceClones

Inherits:
Object
  • Object
show all
Defined in:
lib/telnyx/resources/voice_clones.rb

Overview

Capture and manage voice identities as clones for use in text-to-speech synthesis.

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ VoiceClones

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 VoiceClones.

Parameters:



168
169
170
# File 'lib/telnyx/resources/voice_clones.rb', line 168

def initialize(client:)
  @client = client
end

Instance Method Details

#create(params:, request_options: {}) ⇒ Telnyx::Models::VoiceCloneCreateResponse

Creates a new voice clone by capturing the voice identity of an existing voice design. The clone can then be used for text-to-speech synthesis.

Parameters:

Returns:

See Also:



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

def create(params)
  parsed, options = Telnyx::VoiceCloneCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "voice_clones",
    body: parsed[:params],
    model: Telnyx::Models::VoiceCloneCreateResponse,
    options: options
  )
end

#create_from_upload(params:, request_options: {}) ⇒ Telnyx::Models::VoiceCloneCreateFromUploadResponse

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

Creates a new voice clone by uploading an audio file directly. Supported formats: WAV, MP3, FLAC, OGG, M4A. For best results, provide 5–10 seconds of clear speech. Maximum file size: 5MB for Telnyx, 20MB for Minimax.



132
133
134
135
136
137
138
139
140
141
142
# File 'lib/telnyx/resources/voice_clones.rb', line 132

def create_from_upload(params)
  parsed, options = Telnyx::VoiceCloneCreateFromUploadParams.dump_request(params)
  @client.request(
    method: :post,
    path: "voice_clones/from_upload",
    headers: {"content-type" => "multipart/form-data"},
    body: parsed[:params],
    model: Telnyx::Models::VoiceCloneCreateFromUploadResponse,
    options: options
  )
end

#delete(id, request_options: {}) ⇒ nil

Permanently deletes a voice clone. This action cannot be undone.

Parameters:

Returns:

  • (nil)

See Also:



107
108
109
110
111
112
113
114
# File 'lib/telnyx/resources/voice_clones.rb', line 107

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

#download_sample(id, request_options: {}) ⇒ StringIO

Downloads the WAV audio sample that was used to create the voice clone.

Parameters:

Returns:

  • (StringIO)

See Also:



155
156
157
158
159
160
161
162
163
# File 'lib/telnyx/resources/voice_clones.rb', line 155

def download_sample(id, params = {})
  @client.request(
    method: :get,
    path: ["voice_clones/%1$s/sample", id],
    headers: {"accept" => "audio/wav"},
    model: StringIO,
    options: params[:request_options]
  )
end

#list(filter_name: nil, filter_provider: nil, page_number: nil, page_size: nil, sort: nil, request_options: {}) ⇒ Telnyx::Internal::DefaultFlatPagination<Telnyx::Models::VoiceCloneData>

Returns a paginated list of voice clones belonging to the authenticated account.

Parameters:

Returns:

See Also:



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/telnyx/resources/voice_clones.rb', line 78

def list(params = {})
  parsed, options = Telnyx::VoiceCloneListParams.dump_request(params)
  query = Telnyx::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "voice_clones",
    query: query.transform_keys(
      filter_name: "filter[name]",
      filter_provider: "filter[provider]",
      page_number: "page[number]",
      page_size: "page[size]"
    ),
    page: Telnyx::Internal::DefaultFlatPagination,
    model: Telnyx::VoiceCloneData,
    options: options
  )
end

#update(id, name:, gender: nil, language: nil, request_options: {}) ⇒ Telnyx::Models::VoiceCloneUpdateResponse

Updates the name, language, or gender of a voice clone.

Parameters:

Returns:

See Also:



48
49
50
51
52
53
54
55
56
57
# File 'lib/telnyx/resources/voice_clones.rb', line 48

def update(id, params)
  parsed, options = Telnyx::VoiceCloneUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["voice_clones/%1$s", id],
    body: parsed,
    model: Telnyx::Models::VoiceCloneUpdateResponse,
    options: options
  )
end