Group tests for #transcribe

This commit is contained in:
Kitaiti Makoto 2024-10-18 01:29:50 +09:00
parent 81e6df3bab
commit 71b65b00cc

View File

@ -116,13 +116,16 @@ class TestWhisper < Test::Unit::TestCase
assert !@params.split_on_word
end
def test_whisper
sub_test_case "#transcribe" do
def setup
@whisper = Whisper::Context.new(File.join(TOPDIR, '..', '..', 'models', 'ggml-base.en.bin'))
params = Whisper::Params.new
params.print_timestamps = false
@params = Whisper::Params.new
@params.print_timestamps = false
@jfk = File.join(TOPDIR, '..', '..', 'samples', 'jfk.wav')
end
jfk = File.join(TOPDIR, '..', '..', 'samples', 'jfk.wav')
@whisper.transcribe(jfk, params) {|text|
def test_whisper
@whisper.transcribe(@jfk, @params) {|text|
assert_match /ask not what your country can do for you, ask what you can do for your country/, text
}
end
@ -136,18 +139,15 @@ class TestWhisper < Test::Unit::TestCase
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)
@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)
@whisper.transcribe(@jfk, @params)
end
end
def test_build