Class: RunApi::Elevenlabs::Resources::SpeechToText

Inherits:
Object
  • Object
show all
Includes:
Core::ResourceHelpers
Defined in:
lib/runapi/elevenlabs/resources/speech_to_text.rb

Constant Summary collapse

ENDPOINT =
"/api/v1/elevenlabs/speech_to_text"
RESPONSE_CLASS =
Types::SpeechToTextResponse
COMPLETED_RESPONSE_CLASS =
Types::CompletedSpeechToTextResponse

Instance Method Summary collapse

Constructor Details

#initialize(http) ⇒ SpeechToText

Returns a new instance of SpeechToText.



13
14
15
# File 'lib/runapi/elevenlabs/resources/speech_to_text.rb', line 13

def initialize(http)
  @http = http
end

Instance Method Details

#create(**params) ⇒ Object

Raises:

  • (Core::ValidationError)


22
23
24
25
26
# File 'lib/runapi/elevenlabs/resources/speech_to_text.rb', line 22

def create(**params)
  params = compact_params(params)
  raise Core::ValidationError, "audio_url is required" unless param(params, :audio_url)
  request(:post, ENDPOINT, body: params)
end

#get(id) ⇒ Object



28
29
30
# File 'lib/runapi/elevenlabs/resources/speech_to_text.rb', line 28

def get(id)
  request(:get, "#{ENDPOINT}/#{id}")
end

#run(**params) ⇒ Object



17
18
19
20
# File 'lib/runapi/elevenlabs/resources/speech_to_text.rb', line 17

def run(**params)
  task = create(**params)
  poll_until_complete { get(task.id) }
end