Module: RubyLLM::Protocols::Gemini::Transcription

Defined in:
lib/ruby_llm/protocols/gemini/transcription.rb

Overview

Audio transcription helpers for the Gemini API implementation

Constant Summary collapse

DEFAULT_PROMPT =
'Transcribe the provided audio and respond with only the transcript text.'

Instance Method Summary collapse

Instance Method Details

#transcribe(audio_file, model:, language:, format: nil, speaker_names: nil, speaker_references: nil, provider_options: {}, prompt: nil, temperature: nil) ⇒ Object

rubocop:disable-next Lint/UnusedMethodArgument



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/ruby_llm/protocols/gemini/transcription.rb', line 11

def transcribe(audio_file, model:, language:, format: nil, speaker_names: nil,
               speaker_references: nil, provider_options: {}, prompt: nil, temperature: nil)
  raise_transcription_streaming_unsupported if block_given?

  track_usage(:transcription) do
    attachment = Attachment.new(audio_file, config: @config)
    payload = render_transcription_payload(attachment, language:, format:, provider_options:, prompt:,
                                                       temperature:)
    response = @connection.post(transcription_url(model), payload, usage: @usage_tracker)
    parse_transcription_response(response, model:)
  end
end