Class: RubyLLM::Transcription
- Inherits:
-
Object
- Object
- RubyLLM::Transcription
- Defined in:
- lib/ruby_llm/transcription.rb
Overview
Represents a transcription of audio content.
Instance Attribute Summary collapse
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#input_tokens ⇒ Object
readonly
Returns the value of attribute input_tokens.
-
#language ⇒ Object
readonly
Returns the value of attribute language.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#output_tokens ⇒ Object
readonly
Returns the value of attribute output_tokens.
-
#segments ⇒ Object
readonly
Returns the value of attribute segments.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(text:, model:, **attributes) ⇒ Transcription
constructor
A new instance of Transcription.
Constructor Details
#initialize(text:, model:, **attributes) ⇒ Transcription
Returns a new instance of Transcription.
8 9 10 11 12 13 14 15 16 |
# File 'lib/ruby_llm/transcription.rb', line 8 def initialize(text:, model:, **attributes) @text = text @model = model @language = attributes[:language] @duration = attributes[:duration] @segments = attributes[:segments] @input_tokens = attributes[:input_tokens] @output_tokens = attributes[:output_tokens] end |
Instance Attribute Details
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
6 7 8 |
# File 'lib/ruby_llm/transcription.rb', line 6 def duration @duration end |
#input_tokens ⇒ Object (readonly)
Returns the value of attribute input_tokens.
6 7 8 |
# File 'lib/ruby_llm/transcription.rb', line 6 def input_tokens @input_tokens end |
#language ⇒ Object (readonly)
Returns the value of attribute language.
6 7 8 |
# File 'lib/ruby_llm/transcription.rb', line 6 def language @language end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
6 7 8 |
# File 'lib/ruby_llm/transcription.rb', line 6 def model @model end |
#output_tokens ⇒ Object (readonly)
Returns the value of attribute output_tokens.
6 7 8 |
# File 'lib/ruby_llm/transcription.rb', line 6 def output_tokens @output_tokens end |
#segments ⇒ Object (readonly)
Returns the value of attribute segments.
6 7 8 |
# File 'lib/ruby_llm/transcription.rb', line 6 def segments @segments end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
6 7 8 |
# File 'lib/ruby_llm/transcription.rb', line 6 def text @text end |
Class Method Details
.transcribe(audio_file, **kwargs) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ruby_llm/transcription.rb', line 18 def self.transcribe(audio_file, **kwargs) model = kwargs.delete(:model) language = kwargs.delete(:language) provider = kwargs.delete(:provider) assume_model_exists = kwargs.delete(:assume_model_exists) { false } context = kwargs.delete(:context) = kwargs config = context&.config || RubyLLM.config model ||= config.default_transcription_model model, provider_instance = Models.resolve(model, provider: provider, assume_exists: assume_model_exists, config: config) model_id = model.id provider_instance.transcribe(audio_file, model: model_id, language:, **) end |