mirror of
https://github.com/ggerganov/whisper.cpp.git
synced 2024-12-24 06:46:37 +00:00
Group tests for #transcribe
This commit is contained in:
parent
81e6df3bab
commit
71b65b00cc
@ -116,38 +116,38 @@ class TestWhisper < Test::Unit::TestCase
|
|||||||
assert !@params.split_on_word
|
assert !@params.split_on_word
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_whisper
|
sub_test_case "#transcribe" do
|
||||||
@whisper = Whisper::Context.new(File.join(TOPDIR, '..', '..', 'models', 'ggml-base.en.bin'))
|
def setup
|
||||||
params = Whisper::Params.new
|
@whisper = Whisper::Context.new(File.join(TOPDIR, '..', '..', 'models', 'ggml-base.en.bin'))
|
||||||
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')
|
def test_whisper
|
||||||
@whisper.transcribe(jfk, params) {|text|
|
@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
|
assert_match /ask not what your country can do for you, ask what you can do for your country/, text
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_new_segment_callback_lambda
|
def test_new_segment_callback_lambda
|
||||||
counter = 0
|
counter = 0
|
||||||
@params.new_segment_callback = ->(text, start_time, end_time, index) {
|
@params.new_segment_callback = ->(text, start_time, end_time, index) {
|
||||||
assert_kind_of String, text
|
assert_kind_of String, text
|
||||||
assert_kind_of Integer, start_time
|
assert_kind_of Integer, start_time
|
||||||
assert_kind_of Integer, end_time
|
assert_kind_of Integer, end_time
|
||||||
assert_same index, counter
|
assert_same index, counter
|
||||||
counter += 1
|
counter += 1
|
||||||
}
|
}
|
||||||
whisper = Whisper::Context.new(File.join(TOPDIR, '..', '..', 'models', 'ggml-base.en.bin'))
|
@whisper.transcribe(@jfk, @params)
|
||||||
jfk = File.join(TOPDIR, '..', '..', 'samples', 'jfk.wav')
|
end
|
||||||
whisper.transcribe(jfk, @params)
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_new_segment_callback_proc
|
def test_new_segment_callback_proc
|
||||||
@params.new_segment_callback = proc {|text| # proc checks arguments loosly
|
@params.new_segment_callback = proc {|text| # proc checks arguments loosly
|
||||||
assert_kind_of String, text
|
assert_kind_of String, text
|
||||||
}
|
}
|
||||||
whisper = Whisper::Context.new(File.join(TOPDIR, '..', '..', 'models', 'ggml-base.en.bin'))
|
@whisper.transcribe(@jfk, @params)
|
||||||
jfk = File.join(TOPDIR, '..', '..', 'samples', 'jfk.wav')
|
end
|
||||||
whisper.transcribe(jfk, @params)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_build
|
def test_build
|
||||||
|
Loading…
Reference in New Issue
Block a user