Module: RubyLLM::Pollinations::Provider::Transcription

Included in:
Pollinations
Defined in:
lib/ruby_llm/pollinations/provider/transcription.rb

Constant Summary collapse

SUPPORTED_MODELS =
%w[whisper-large-v3 whisper-1].freeze
DEFAULT_MODEL =
'whisper-large-v3'
RESPONSE_FORMATS =
%w[json text srt verbose_json vtt].freeze

Class Method Summary collapse

Class Method Details

.parse_transcription_response(response, model:) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/ruby_llm/pollinations/provider/transcription.rb', line 28

def parse_transcription_response(response, model:)
  data = response.body
  return RubyLLM::Transcription.new(text: data, model: model) if data.is_a?(String)

  RubyLLM::Transcription.new(
    text: data['text'],
    model: model,
    language: data['language'],
    duration: data['duration'],
    segments: data['segments']
  )
end

.render_transcription_payload(file_part, model:, language:, **options) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/ruby_llm/pollinations/provider/transcription.rb', line 17

def render_transcription_payload(file_part, model:, language:, **options)
  {
    file: file_part,
    model: model || DEFAULT_MODEL,
    language: language,
    prompt: options[:prompt],
    response_format: options[:response_format] || 'json',
    temperature: options[:temperature]
  }.compact
end

.transcription_url ⇒ Object



13
14
15
# File 'lib/ruby_llm/pollinations/provider/transcription.rb', line 13

def transcription_url
  'v1/audio/transcriptions'
end