Skip to content

Commit 71b65b0

Browse files
committed
Group tests for #transcribe
1 parent 81e6df3 commit 71b65b0

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

bindings/ruby/tests/test_whisper.rb

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -116,38 +116,38 @@ def test_split_on_word
116116
assert !@params.split_on_word
117117
end
118118

119-
def test_whisper
120-
@whisper = Whisper::Context.new(File.join(TOPDIR, '..', '..', 'models', 'ggml-base.en.bin'))
121-
params = Whisper::Params.new
122-
params.print_timestamps = false
123-
124-
jfk = File.join(TOPDIR, '..', '..', 'samples', 'jfk.wav')
125-
@whisper.transcribe(jfk, params) {|text|
126-
assert_match /ask not what your country can do for you, ask what you can do for your country/, text
127-
}
128-
end
129-
130-
def test_new_segment_callback_lambda
131-
counter = 0
132-
@params.new_segment_callback = ->(text, start_time, end_time, index) {
133-
assert_kind_of String, text
134-
assert_kind_of Integer, start_time
135-
assert_kind_of Integer, end_time
136-
assert_same index, counter
137-
counter += 1
138-
}
139-
whisper = Whisper::Context.new(File.join(TOPDIR, '..', '..', 'models', 'ggml-base.en.bin'))
140-
jfk = File.join(TOPDIR, '..', '..', 'samples', 'jfk.wav')
141-
whisper.transcribe(jfk, @params)
142-
end
143-
144-
def test_new_segment_callback_proc
145-
@params.new_segment_callback = proc {|text| # proc checks arguments loosly
146-
assert_kind_of String, text
147-
}
148-
whisper = Whisper::Context.new(File.join(TOPDIR, '..', '..', 'models', 'ggml-base.en.bin'))
149-
jfk = File.join(TOPDIR, '..', '..', 'samples', 'jfk.wav')
150-
whisper.transcribe(jfk, @params)
119+
sub_test_case "#transcribe" do
120+
def setup
121+
@whisper = Whisper::Context.new(File.join(TOPDIR, '..', '..', 'models', 'ggml-base.en.bin'))
122+
@params = Whisper::Params.new
123+
@params.print_timestamps = false
124+
@jfk = File.join(TOPDIR, '..', '..', 'samples', 'jfk.wav')
125+
end
126+
127+
def test_whisper
128+
@whisper.transcribe(@jfk, @params) {|text|
129+
assert_match /ask not what your country can do for you, ask what you can do for your country/, text
130+
}
131+
end
132+
133+
def test_new_segment_callback_lambda
134+
counter = 0
135+
@params.new_segment_callback = ->(text, start_time, end_time, index) {
136+
assert_kind_of String, text
137+
assert_kind_of Integer, start_time
138+
assert_kind_of Integer, end_time
139+
assert_same index, counter
140+
counter += 1
141+
}
142+
@whisper.transcribe(@jfk, @params)
143+
end
144+
145+
def test_new_segment_callback_proc
146+
@params.new_segment_callback = proc {|text| # proc checks arguments loosly
147+
assert_kind_of String, text
148+
}
149+
@whisper.transcribe(@jfk, @params)
150+
end
151151
end
152152

153153
def test_build

0 commit comments

Comments
 (0)