Module: RubyLLM::Protocols::Gemini::FileTranscription
- Defined in:
- lib/ruby_llm/protocols/gemini/file_transcription.rb
Overview
:nodoc: all
Instance Method Summary collapse
- #transcribe(audio_file, model:, language:, format: nil, speaker_names: nil, speaker_references: nil, provider_options: {}, prompt: nil, temperature: nil) ⇒ Object
- #validate_transcription_request(format:, speaker_references:, temperature:) ⇒ Object
Instance Method Details
#transcribe(audio_file, model:, language:, format: nil, speaker_names: nil, speaker_references: nil, provider_options: {}, prompt: nil, temperature: nil) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/ruby_llm/protocols/gemini/file_transcription.rb', line 7 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? validate_transcription_request(format:, speaker_references:, temperature:) = Attachment.wrap(audio_file, config: @config) unless .one? && .first.audio? raise ArgumentError, 'Dedicated transcription requires exactly one audio file' end track_usage(:transcription) do payload = render_transcription_payload(.first, model:, language:, speaker_names:, provider_options:, prompt:) response = @connection.post(transcription_url(model), payload, usage: @usage_tracker) parse_transcription_response(response, model:) end end |
#validate_transcription_request(format:, speaker_references:, temperature:) ⇒ Object
24 25 26 27 28 |
# File 'lib/ruby_llm/protocols/gemini/file_transcription.rb', line 24 def validate_transcription_request(format:, speaker_references:, temperature:) return unless format || speaker_references || temperature raise ArgumentError, 'Dedicated transcription does not accept format, speaker references, or temperature' end |