Class: RunApi::Elevenlabs::Resources::TextToSound
- Inherits:
-
Object
- Object
- RunApi::Elevenlabs::Resources::TextToSound
- Includes:
- Core::ResourceHelpers
- Defined in:
- lib/runapi/elevenlabs/resources/text_to_sound.rb
Constant Summary collapse
- ENDPOINT =
"/api/v1/elevenlabs/text_to_sound"- RESPONSE_CLASS =
Types::AudioTaskResponse
- COMPLETED_RESPONSE_CLASS =
Types::CompletedAudioTaskResponse
Instance Method Summary collapse
- #create(**params) ⇒ Object
- #get(id) ⇒ Object
-
#initialize(http) ⇒ TextToSound
constructor
A new instance of TextToSound.
- #run(**params) ⇒ Object
Constructor Details
#initialize(http) ⇒ TextToSound
Returns a new instance of TextToSound.
13 14 15 |
# File 'lib/runapi/elevenlabs/resources/text_to_sound.rb', line 13 def initialize(http) @http = http end |
Instance Method Details
#create(**params) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/runapi/elevenlabs/resources/text_to_sound.rb', line 22 def create(**params) params = compact_params(params) raise Core::ValidationError, "text is required" unless param(params, :text) if param(params, :output_format) && !Types::TEXT_TO_SOUND_OUTPUT_FORMATS.include?(param(params, :output_format)) raise Core::ValidationError, "Invalid output_format" end request(:post, ENDPOINT, body: params) end |
#get(id) ⇒ Object
31 32 33 |
# File 'lib/runapi/elevenlabs/resources/text_to_sound.rb', line 31 def get(id) request(:get, "#{ENDPOINT}/#{id}") end |
#run(**params) ⇒ Object
17 18 19 20 |
# File 'lib/runapi/elevenlabs/resources/text_to_sound.rb', line 17 def run(**params) task = create(**params) poll_until_complete { get(task.id) } end |