Class: Whisper::Segment

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

Instance Method Summary collapse

Methods included from Output::Segment

#to_srt_cue, #to_webvtt_cue

Instance Method Details

#deconstruct_keysdeconstructed_keys

Possible keys: :start_time, :end_time, :text, :no_speech_prob, :speaker_turn_next

 whisper.each_segment do |segment|
   segment => {start_time:, end_time:, text:, no_speech_prob:, speaker_turn_next:}

   puts "[#{start_time} --> #{end_time}] #{text} (no speech prob: #{no_speech_prob}#{speaker_turn_next ? ', speaker turns next' : ''})"
 end

Parameters:

  • (Array[:start_time | :end_time | :text | :no_speech_prob | :speaker_turn_next | :n_tokens], nil)

Returns:

  • (deconstructed_keys)


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

def deconstruct_keys: (Array[:start_time | :end_time | :text | :no_speech_prob | :speaker_turn_next | :n_tokens] | nil) -> deconstructed_keys

#each_tokenvoid #each_tokenEnumerator[Token]

Yields each Whisper::Token:

whisper.each_segment.first.each_token do |token|
  p token
end

Returns an Enumerator if no block is given:

whisper.each_segment.first.each_token.to_a # => [#<Whisper::Token>, ...]

Overloads:

  • #each_tokenvoid

    This method returns an undefined value.

  • #each_tokenEnumerator[Token]

    Returns:

Yields:

Yield Parameters:

Yield Returns:

  • (void)


537
538
# File 'sig/whisper.rbs', line 537

def each_token: { (Token) -> void } -> void
| () -> Enumerator[Token]

#end_timeInteger

End time in milliseconds.

Returns:

  • (Integer)


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

def end_time: () -> Integer

#n_tokensInteger

Get number of tokens in the segment

Returns:

  • (Integer)


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

def n_tokens: () -> Integer

#no_speech_probFloat

Returns:

  • (Float)


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

def no_speech_prob: () -> Float

#speaker_turn_next?true, false

Whether the next segment is predicted as a speaker turn.

Returns:

  • (true, false)


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

def speaker_turn_next?: () -> (true | false)

#start_timeInteger

Start time in milliseconds.

Returns:

  • (Integer)


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

def start_time: () -> Integer

#textString

Returns:

  • (String)


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

def text: () -> String