mirror of
https://github.com/ggerganov/whisper.cpp.git
synced 2024-12-19 04:37:51 +00:00
3a27b2b91b
* Remove Whisper::Model.[] * Fix Whisper::Model::URI#request * Make Whisper::Context#initialize accept pre-converted model name * Use downloading pre-converted model feature for testing * Update README * Remove unnecessary task * Move whisper/model.rb -> whisper/model/uri.rb * Update document comment of Whisper::Context#initialize * Don't show download progress when not tty * Pass String to raise * Use cache model file if download fails * Add test for auto download * Specify required Ruby version * Fix a typo * Remove unnecessary flags * Initialize Whisper::Params#diarize explicitely * Remove redundant code from README for simplicity * Add Whisper::Params#no_speech_thold attribute * Add test for Whisper::Params#no_speech_thold
72 lines
2.1 KiB
Ruby
72 lines
2.1 KiB
Ruby
require_relative "helper"
|
|
require "pathname"
|
|
|
|
class TestModel < TestBase
|
|
def test_model
|
|
whisper = Whisper::Context.new("base.en")
|
|
assert_instance_of Whisper::Model, whisper.model
|
|
end
|
|
|
|
def test_attributes
|
|
whisper = Whisper::Context.new("base.en")
|
|
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
|
|
model = Whisper::Context.new("base.en").model
|
|
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
|
|
|
|
def test_pathname
|
|
path = Pathname(Whisper::Model.pre_converted_models["base.en"].to_path)
|
|
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
|
|
|
|
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
|
|
end
|