Class: GroqRuby::Resources::Audio::Transcriptions
- Defined in:
- lib/groq_ruby/resources/audio/transcriptions.rb
Overview
‘client.audio.transcriptions.create(…)` — speech to text. Either an in-memory `file:` IO or a remote `url:` must be supplied.
Constant Summary collapse
- PATH =
"/openai/v1/audio/transcriptions".freeze
- SCHEMA =
Dry::Schema.define do required(:model).filled(:string) optional(:language).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) optional(:timestamp_granularities).value(:array) 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::Transcription
29 30 31 32 33 34 35 |
# File 'lib/groq_ruby/resources/audio/transcriptions.rb', line 29 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::Transcription.from_hash(perform(request)) end |