Module: RubyLLM::Protocols::OpenRouter::Transcription
- Included in:
- RubyLLM::Providers::OpenRouter::ChatCompletions
- Defined in:
- lib/ruby_llm/protocols/openrouter/transcription.rb
Overview
:nodoc: all
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, &block) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/ruby_llm/protocols/openrouter/transcription.rb', line 7 def transcribe(audio_file, model:, language:, format: nil, speaker_names: nil, speaker_references: nil, provider_options: {}, prompt: nil, temperature: nil, &block) raise_transcription_streaming_unsupported if block (format:, speaker_names:, speaker_references:, prompt:) track_usage(:transcription) do = audio_file.is_a?(Attachment) ? audio_file : Attachment.new(audio_file, config: @config) payload = { model:, input_audio: { data: Base64.strict_encode64(.content), format: .format }, language:, temperature:, response_format: format || (speaker_names ? 'verbose_json' : 'json') }.compact if speaker_names payload[:provider] = { options: { azure: { diarization: { enabled: true } }, deepgram: { diarize: true } } } end response = @connection.post(transcription_url, Support::Utils.deep_merge(payload, ), usage: @usage_tracker) parse_transcription_response(response, model:) end end |