mirror of
https://github.com/ggerganov/whisper.cpp.git
synced 2025-06-11 11:41:34 +00:00
* Fix a typo * Don't allocate output string unless needed * Add methods to output SRT and WebVTT * Add tests for output methods * Make constants for output private * Add signatures for output methods * Add document on output methods * Fix method name: Segment#speaker_next_turn? -> #speacker_turn_next? * Add Whisper::Segment#descotruct_keys * Add test for Whisper::Context#descotruct_keys * Add signature of Whisper::Segment#deconstruct_keys * Use parentheses to suppress warning * Update date
16 lines
368 B
Ruby
16 lines
368 B
Ruby
module Whisper
|
|
class Context
|
|
def to_srt
|
|
each_segment.with_index.reduce("") {|srt, (segment, index)|
|
|
srt << "#{index + 1}\n#{segment.to_srt_cue}\n"
|
|
}
|
|
end
|
|
|
|
def to_webvtt
|
|
each_segment.with_index.reduce("WEBVTT\n\n") {|webvtt, (segment, index)|
|
|
webvtt << "#{index + 1}\n#{segment.to_webvtt_cue}\n"
|
|
}
|
|
end
|
|
end
|
|
end
|