Skip to content

Commit

Permalink
Add tests for Params#new_segment_callback=
Browse files Browse the repository at this point in the history
  • Loading branch information
KitaitiMakoto committed Oct 19, 2024
1 parent 647c5f6 commit 81e6df3
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions bindings/ruby/tests/test_whisper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,29 @@ def test_whisper
}
end

def test_new_segment_callback_lambda
counter = 0
@params.new_segment_callback = ->(text, start_time, end_time, index) {
assert_kind_of String, text
assert_kind_of Integer, start_time
assert_kind_of Integer, end_time
assert_same index, counter
counter += 1
}
whisper = Whisper::Context.new(File.join(TOPDIR, '..', '..', 'models', 'ggml-base.en.bin'))
jfk = File.join(TOPDIR, '..', '..', 'samples', 'jfk.wav')
whisper.transcribe(jfk, @params)
end

def test_new_segment_callback_proc
@params.new_segment_callback = proc {|text| # proc checks arguments loosly
assert_kind_of String, text
}
whisper = Whisper::Context.new(File.join(TOPDIR, '..', '..', 'models', 'ggml-base.en.bin'))
jfk = File.join(TOPDIR, '..', '..', 'samples', 'jfk.wav')
whisper.transcribe(jfk, @params)
end

def test_build
Tempfile.create do |file|
assert system("gem", "build", "whispercpp.gemspec", "--output", file.to_path.shellescape, exception: true)
Expand Down

0 comments on commit 81e6df3

Please sign in to comment.