Class: RubyLLM::Transcription::WavAudio

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_llm/transcription/wav_audio.rb

Overview

:nodoc: all

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content) ⇒ WavAudio

Returns a new instance of WavAudio.

Raises:



8
9
10
11
12
# File 'lib/ruby_llm/transcription/wav_audio.rb', line 8

def initialize(content)
  content = wav_content(content)
  parse_chunks(content)
  raise ArgumentError, 'WAV file must contain audio data and format information' unless @data && @sample_rate
end

Instance Attribute Details

#bits_per_sampleObject (readonly)

Returns the value of attribute bits_per_sample.



6
7
8
# File 'lib/ruby_llm/transcription/wav_audio.rb', line 6

def bits_per_sample
  @bits_per_sample
end

#channelsObject (readonly)

Returns the value of attribute channels.



6
7
8
# File 'lib/ruby_llm/transcription/wav_audio.rb', line 6

def channels
  @channels
end

#dataObject (readonly)

Returns the value of attribute data.



6
7
8
# File 'lib/ruby_llm/transcription/wav_audio.rb', line 6

def data
  @data
end

#encodingObject (readonly)

Returns the value of attribute encoding.



6
7
8
# File 'lib/ruby_llm/transcription/wav_audio.rb', line 6

def encoding
  @encoding
end

#sample_rateObject (readonly)

Returns the value of attribute sample_rate.



6
7
8
# File 'lib/ruby_llm/transcription/wav_audio.rb', line 6

def sample_rate
  @sample_rate
end

Instance Method Details

#durationObject



14
15
16
# File 'lib/ruby_llm/transcription/wav_audio.rb', line 14

def duration
  data.bytesize.fdiv(sample_rate * channels * bits_per_sample / 8)
end