Class: GroqRuby::Resources::Audio::Translations
- Defined in:
- lib/groq_ruby/resources/audio/translations.rb
Overview
‘client.audio.translations.create(…)` — translates speech in any supported language into English text.
Constant Summary collapse
- PATH =
"/openai/v1/audio/translations".freeze
- SCHEMA =
Dry::Schema.define do required(:model).filled(:string) optional(:prompt).filled(:string) optional(:response_format).filled(:string, included_in?: %w[json text srt verbose_json vtt]) optional(:temperature).filled(:float, gteq?: 0.0, lteq?: 1.0) end
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from GroqRuby::Resources::Base
Instance Method Details
#create(file: nil, filename: nil, url: nil, **params) ⇒ GroqRuby::Models::Translation
26 27 28 29 30 31 32 |
# File 'lib/groq_ruby/resources/audio/translations.rb', line 26 def create(file: nil, filename: nil, url: nil, **params) raise ParameterError, {file: ["either file or url is required"]} if file.nil? && url.nil? body = validate!(SCHEMA, params) multipart = build_multipart(file: file, filename: filename, url: url, body: body) request = Request.new(method: :post, path: PATH, body: multipart.body, content_type: multipart.content_type) GroqRuby::Models::Translation.from_hash(perform(request)) end |