mirror of
https://github.com/ggml-org/whisper.cpp.git
synced 2026-10-22 03:48:19 +02:00
ruby : Add #free method, check MemoryView strictly (#4032)
* Bump version to 1.3.9 * Fix JFKReader's format * Add Whisper::Context#free * Add test for Whisper::Context#free * Add Whisper::Context#free to RBS * Add Whisper::VAD::Context#free * Add test for Whisper::VAD::Context#free * Add Whisper::VAD::Context#free to RBS * Add Parakeet::Context#free * Add test for Parakeet::Context#free * Add Parakeet::Context#free to RBS * Check MemoryView format more strictly * Fallback MemoryView flags to SIMPLE when MemoryView not available * Add changelog entries * Update document on callbacks * Remove whitespace Co-authored-by: Daniel Bevenius <daniel.bevenius@gmail.com> --------- Co-authored-by: Daniel Bevenius <daniel.bevenius@gmail.com>
This commit is contained in:
co-authored by
Daniel Bevenius
parent
eacbd8234c
commit
642b5d3260
@@ -69,7 +69,7 @@ jfk_reader_get_memory_view(const VALUE obj, rb_memory_view_t *view, int flags)
|
||||
view->data = (void *)args.data;
|
||||
view->byte_size = sizeof(float) * n_samples;
|
||||
view->readonly = true;
|
||||
view->format = "f";
|
||||
view->format = "e";
|
||||
view->item_size = sizeof(float);
|
||||
view->item_desc.components = NULL;
|
||||
view->item_desc.length = 0;
|
||||
|
||||
@@ -113,4 +113,11 @@ class TestParakeetContext < TestBase
|
||||
@parakeet.transcribe "nothing", @params
|
||||
end
|
||||
end
|
||||
|
||||
def test_free
|
||||
@parakeet.free
|
||||
assert_raise RuntimeError do
|
||||
@parakeet.transcribe AUDIO, @params
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -25,6 +25,14 @@ class TestVADContext < TestBase
|
||||
end
|
||||
end
|
||||
|
||||
def test_free
|
||||
vad = Whisper::VAD::Context.new("silero-v6.2.0")
|
||||
vad.free
|
||||
assert_raise RuntimeError do
|
||||
vad.detect(AUDIO, Whisper::VAD::Params.new)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def assert_segments(segments)
|
||||
|
||||
@@ -50,6 +50,15 @@ class TestWhisper < TestBase
|
||||
end
|
||||
end
|
||||
|
||||
def test_free
|
||||
whisper = Whisper::Context.new("base.en")
|
||||
whisper.free
|
||||
|
||||
assert_raise RuntimeError do
|
||||
whisper.model_type
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def without_log_callback
|
||||
|
||||
Reference in New Issue
Block a user