Class: Whisper::Parakeet::Context

Inherits:
Object
  • Object
show all
Includes:
Output::Context
Defined in:
sig/whisper.rbs

Defined Under Namespace

Classes: Params

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Output::Context

#to_srt, #to_webvtt

Class Method Details

.newinstance

Load a Parakeet model from the given file path.

Parameters:

  • (String, path, ::URI::HTTP)
  • (Params)

Returns:

  • (instance)


636
# File 'sig/whisper.rbs', line 636

def self.new: (String | path | ::URI::HTTP, ?Params) -> instance

Instance Method Details

#each_segmentvoid #each_segmentEnumerator[Segment]

Yields each Whisper::Parakeet::Segment:

parakeet.transcribe("path/to/audio.wav", params)
parakeet.each_segment do |segment|
  puts segment.text
end

Returns an Enumerator if no block given:

parakeet.transcribe("path/to/audio.wav", params)
enum = parakeet.each_segment
enum.to_a # => [#<Whisper::Parakeet::Segment>, ...]

Overloads:

  • #each_segmentvoid

    This method returns an undefined value.

  • #each_segmentEnumerator[Segment]

    Returns:

Yields:

Yield Parameters:

Yield Returns:

  • (void)


708
709
# File 'sig/whisper.rbs', line 708

def each_segment: { (Segment) -> void } -> void
| () -> Enumerator[Segment]

#full(arg0, samples, n_samples) ⇒ self #full(arg0, arg1, n_samples) ⇒ self

Run the entire model: PCM -> log mel spectrogram -> encoder -> decoder -> text. Not thread safe for the same context.

The second argument samples must be an array of samples, respond to :length, or be a MemoryView of an array of float. It must be 32 bit float PCM audio data.

Overloads:



648
649
# File 'sig/whisper.rbs', line 648

def full: (Whisper::Parakeet::Params, Array[Float] samples, ?Integer n_samples) -> self
| (Whisper::Parakeet::Params, _Samples, ?Integer n_samples) -> self

#full_get_segment_t0Integer

Start time of a segment indexed by segment_index in centiseconds (10 times milliseconds).

full_get_segment_t0(3) # => 1668 (16680 ms)

Parameters:

  • segment_index (Integer)

Returns:

  • (Integer)


659
# File 'sig/whisper.rbs', line 659

def full_get_segment_t0: (Integer segment_index) -> Integer

#full_get_segment_t1Integer

End time of a segment indexed by segment_index in centiseconds (10 times milliseconds).

full_get_segment_t1(3) # => 1668 (16680 ms)

Parameters:

  • segment_index (Integer)

Returns:

  • (Integer)


665
# File 'sig/whisper.rbs', line 665

def full_get_segment_t1: (Integer segment_index) -> Integer

#full_get_segment_textString

Text of a segment indexed by segment_index.

full_get_segment_text(3) # => "ask not what your country can do for you, ..."

Parameters:

  • segment_index (Integer)

Returns:

  • (String)


671
# File 'sig/whisper.rbs', line 671

def full_get_segment_text: (Integer segment_index) -> String

#full_get_token_dataToken

Token data of the token indexed by token_index in the segment indexed by segment_index.

Parameters:

  • segment_index (Integer)
  • token_index (Integer)

Returns:



691
# File 'sig/whisper.rbs', line 691

def full_get_token_data: (Integer segment_index, Integer token_index) -> Token

#full_get_token_idInteger

Token id of the token indexed by token_index in the segment indexed by segment_index.

Parameters:

  • segment_index (Integer)
  • token_index (Integer)

Returns:

  • (Integer)


683
# File 'sig/whisper.rbs', line 683

def full_get_token_id: (Integer segment_index, Integer token_index) -> Integer

#full_get_token_pFloat

Probability of the token indexed by token_index in the segment indexed by segment_index.

Parameters:

  • segment_index (Integer)
  • token_index (Integer)

Returns:

  • (Float)


687
# File 'sig/whisper.rbs', line 687

def full_get_token_p: (Integer segment_index, Integer token_index) -> Float

#full_get_token_textString

Text of the token indexed by token_index in the segment indexed by segment_index.

Parameters:

  • segment_index (Integer)
  • token_index (Integer)

Returns:

  • (String)


679
# File 'sig/whisper.rbs', line 679

def full_get_token_text: (Integer segment_index, Integer token_index) -> String

#full_n_segmentsInteger

Number of generated text segments.

Returns:

  • (Integer)


653
# File 'sig/whisper.rbs', line 653

def full_n_segments: () -> Integer

#full_n_tokensInteger

Number of tokens in the segment indexed by segment_index.

Parameters:

  • segment_index (Integer)

Returns:

  • (Integer)


675
# File 'sig/whisper.rbs', line 675

def full_n_tokens: (Integer segment_index) -> Integer

#modelModel

Returns:



693
# File 'sig/whisper.rbs', line 693

def model: () -> Model

#transcribeself

Transcribe a single audio file.

Parameters:

Returns:

  • (self)


640
# File 'sig/whisper.rbs', line 640

def transcribe: (path audio_file_path, Whisper::Parakeet::Params) -> self