@@ -127,6 +127,29 @@ def test_whisper
127127    } 
128128  end 
129129
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 ) 
151+   end 
152+ 
130153  def  test_build 
131154    Tempfile . create  do  |file |
132155      assert  system ( "gem" ,  "build" ,  "whispercpp.gemspec" ,  "--output" ,  file . to_path . shellescape ,  exception : true ) 
0 commit comments