2024-11-13 19:52:56 +00:00
|
|
|
require_relative "helper"
|
2024-12-09 11:17:50 +00:00
|
|
|
require "pathname"
|
2024-11-13 19:52:56 +00:00
|
|
|
|
|
|
|
class TestModel < TestBase
|
|
|
|
def test_model
|
2024-12-18 09:00:50 +00:00
|
|
|
whisper = Whisper::Context.new("base.en")
|
2024-11-13 19:52:56 +00:00
|
|
|
assert_instance_of Whisper::Model, whisper.model
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_attributes
|
2024-12-18 09:00:50 +00:00
|
|
|
whisper = Whisper::Context.new("base.en")
|
2024-11-13 19:52:56 +00:00
|
|
|
model = whisper.model
|
|
|
|
|
|
|
|
assert_equal 51864, model.n_vocab
|
|
|
|
assert_equal 1500, model.n_audio_ctx
|
|
|
|
assert_equal 512, model.n_audio_state
|
|
|
|
assert_equal 8, model.n_audio_head
|
|
|
|
assert_equal 6, model.n_audio_layer
|
|
|
|
assert_equal 448, model.n_text_ctx
|
|
|
|
assert_equal 512, model.n_text_state
|
|
|
|
assert_equal 8, model.n_text_head
|
|
|
|
assert_equal 6, model.n_text_layer
|
|
|
|
assert_equal 80, model.n_mels
|
|
|
|
assert_equal 1, model.ftype
|
|
|
|
assert_equal "base", model.type
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_gc
|
2024-12-18 09:00:50 +00:00
|
|
|
model = Whisper::Context.new("base.en").model
|
2024-11-13 19:52:56 +00:00
|
|
|
GC.start
|
|
|
|
|
|
|
|
assert_equal 51864, model.n_vocab
|
|
|
|
assert_equal 1500, model.n_audio_ctx
|
|
|
|
assert_equal 512, model.n_audio_state
|
|
|
|
assert_equal 8, model.n_audio_head
|
|
|
|
assert_equal 6, model.n_audio_layer
|
|
|
|
assert_equal 448, model.n_text_ctx
|
|
|
|
assert_equal 512, model.n_text_state
|
|
|
|
assert_equal 8, model.n_text_head
|
|
|
|
assert_equal 6, model.n_text_layer
|
|
|
|
assert_equal 80, model.n_mels
|
|
|
|
assert_equal 1, model.ftype
|
|
|
|
assert_equal "base", model.type
|
|
|
|
end
|
2024-12-09 11:17:50 +00:00
|
|
|
|
|
|
|
def test_pathname
|
2024-12-18 09:00:50 +00:00
|
|
|
path = Pathname(Whisper::Model.pre_converted_models["base.en"].to_path)
|
2024-12-09 11:17:50 +00:00
|
|
|
whisper = Whisper::Context.new(path)
|
|
|
|
model = whisper.model
|
|
|
|
|
|
|
|
assert_equal 51864, model.n_vocab
|
|
|
|
assert_equal 1500, model.n_audio_ctx
|
|
|
|
assert_equal 512, model.n_audio_state
|
|
|
|
assert_equal 8, model.n_audio_head
|
|
|
|
assert_equal 6, model.n_audio_layer
|
|
|
|
assert_equal 448, model.n_text_ctx
|
|
|
|
assert_equal 512, model.n_text_state
|
|
|
|
assert_equal 8, model.n_text_head
|
|
|
|
assert_equal 6, model.n_text_layer
|
|
|
|
assert_equal 80, model.n_mels
|
|
|
|
assert_equal 1, model.ftype
|
|
|
|
assert_equal "base", model.type
|
|
|
|
end
|
2024-12-18 09:00:50 +00:00
|
|
|
|
|
|
|
def test_auto_download
|
|
|
|
path = Whisper::Model.pre_converted_models["base.en"].to_path
|
|
|
|
|
|
|
|
assert_path_exist path
|
|
|
|
assert_equal 147964211, File.size(path)
|
|
|
|
end
|
2024-11-13 19:52:56 +00:00
|
|
|
end
|