Class: ElevenlabsClient::TextToDialogue
- Inherits:
-
Object
- Object
- ElevenlabsClient::TextToDialogue
- Defined in:
- lib/elevenlabs_client/endpoints/text_to_dialogue.rb
Instance Method Summary collapse
-
#convert(inputs, **options) ⇒ String
(also: #text_to_dialogue)
POST /v1/text-to-dialogue Converts a list of text and voice ID pairs into speech (dialogue) and returns audio.
-
#initialize(client) ⇒ TextToDialogue
constructor
A new instance of TextToDialogue.
-
#stream(inputs, **options, &block) ⇒ Faraday::Response
(also: #text_to_dialogue_stream)
POST /v1/text-to-dialogue/stream Converts a list of text and voice ID pairs into speech (dialogue) and returns an audio stream.
Constructor Details
#initialize(client) ⇒ TextToDialogue
Returns a new instance of TextToDialogue.
5 6 7 |
# File 'lib/elevenlabs_client/endpoints/text_to_dialogue.rb', line 5 def initialize(client) @client = client end |
Instance Method Details
#convert(inputs, **options) ⇒ String Also known as: text_to_dialogue
POST /v1/text-to-dialogue Converts a list of text and voice ID pairs into speech (dialogue) and returns audio. Documentation: https://elevenlabs.io/docs/api-reference/text-to-dialogue/convert
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/elevenlabs_client/endpoints/text_to_dialogue.rb', line 21 def convert(inputs, **) endpoint = "/v1/text-to-dialogue" request_body = { inputs: inputs } # Add optional parameters request_body[:model_id] = [:model_id] if [:model_id] request_body[:settings] = [:settings] if [:settings] && ![:settings].empty? request_body[:seed] = [:seed] if [:seed] @client.post_binary(endpoint, request_body) end |
#stream(inputs, **options, &block) ⇒ Faraday::Response Also known as: text_to_dialogue_stream
POST /v1/text-to-dialogue/stream Converts a list of text and voice ID pairs into speech (dialogue) and returns an audio stream. Documentation: https://elevenlabs.io/docs/api-reference/text-to-dialogue/stream
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/elevenlabs_client/endpoints/text_to_dialogue.rb', line 48 def stream(inputs, **, &block) # Build endpoint with optional query params output_format = [:output_format] || "mp3_44100_128" endpoint = "/v1/text-to-dialogue/stream?output_format=#{output_format}" # Build request body request_body = { inputs: inputs } request_body[:model_id] = [:model_id] if [:model_id] request_body[:language_code] = [:language_code] if [:language_code] request_body[:settings] = [:settings] if [:settings] request_body[:pronunciation_dictionary_locators] = [:pronunciation_dictionary_locators] if [:pronunciation_dictionary_locators] request_body[:seed] = [:seed] if [:seed] request_body[:apply_text_normalization] = [:apply_text_normalization] if [:apply_text_normalization] @client.post_streaming(endpoint, request_body, &block) end |