Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/ruby_llm/providers/openai/transcription.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,18 @@ def parse_transcription_response(response, model:)

usage = data['usage'] || {}

RubyLLM::Transcription.new(
attributes = {
text: data['text'],
model: model,
language: data['language'],
duration: data['duration'],
segments: data['segments'],
input_tokens: usage['input_tokens'] || usage['prompt_tokens'],
output_tokens: usage['output_tokens'] || usage['completion_tokens']
)
}
attributes[:words] = data['words'] if data.key?('words')

RubyLLM::Transcription.new(**attributes)
end
end
end
Expand Down
3 changes: 2 additions & 1 deletion lib/ruby_llm/transcription.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
module RubyLLM
# Represents a transcription of audio content.
class Transcription
attr_reader :text, :model, :language, :duration, :segments, :input_tokens, :output_tokens
attr_reader :text, :model, :language, :duration, :segments, :words, :input_tokens, :output_tokens

def initialize(text:, model:, **attributes)
@text = text
@model = model
@language = attributes[:language]
@duration = attributes[:duration]
@segments = attributes[:segments]
@words = attributes[:words]
@input_tokens = attributes[:input_tokens]
@output_tokens = attributes[:output_tokens]
end
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading