mirror of
https://github.com/ggerganov/whisper.cpp.git
synced 2024-12-19 04:37:51 +00:00
021eef1000
* Add tests for Whisper::Context#full * Add Whisper::Context#full * Add tests for Whisper::Error * Add document of Whisper::Context#full [skip ci] * Add additional signature for Whisper::Context#full * Add description to Whisper::Context#full * Add test for Whisper::Context#full_parallel * Add Whisper::Context#full_parallel * Hide Whisper's instance methods from Ruby code * Add class to test MemoryView * Build test class before running test * Add test for MemoryView * Make Whisper::Context#full and #full_parallel accept MemoryView * Use Ruby 3.1 on CI * Add comment on samples data type * Update README * Update README * Remove unused code
81 lines
1.8 KiB
Ruby
81 lines
1.8 KiB
Ruby
require 'rake/clean'
|
|
require "bundler/gem_tasks"
|
|
require "rake/testtask"
|
|
require_relative "extsources"
|
|
|
|
SOURCES = FileList[]
|
|
|
|
EXTSOURCES.each do |src|
|
|
basename = src.pathmap("%f")
|
|
dest = basename == "LICENSE" ? basename : src.pathmap("%{../..,ext}p")
|
|
dir = dest.pathmap("%d")
|
|
file src
|
|
directory dir
|
|
file dest => [src, dir] do |t|
|
|
cp t.source, t.name
|
|
end
|
|
SOURCES.include dest
|
|
end
|
|
|
|
CLEAN.include SOURCES
|
|
CLEAN.include FileList[
|
|
"ext/*.o",
|
|
"ext/*.metal",
|
|
"ext/whisper.{so,bundle,dll}",
|
|
"ext/depend"
|
|
]
|
|
|
|
task build: FileList[
|
|
"ext/Makefile",
|
|
"ext/ruby_whisper.h",
|
|
"ext/ruby_whisper.cpp",
|
|
"whispercpp.gemspec",
|
|
]
|
|
|
|
directory "pkg"
|
|
CLOBBER.include "pkg"
|
|
|
|
TEST_MODEL = "../../models/ggml-base.en.bin"
|
|
LIB_NAME = "whisper".ext(RbConfig::CONFIG["DLEXT"])
|
|
SO_FILE = File.join("ext", LIB_NAME)
|
|
LIB_FILE = File.join("lib", LIB_NAME)
|
|
|
|
file "ext/Makefile" => ["ext/extconf.rb", "ext/ruby_whisper.h", "ext/ruby_whisper.cpp"] + SOURCES do |t|
|
|
Dir.chdir "ext" do
|
|
ruby "extconf.rb"
|
|
end
|
|
end
|
|
|
|
file SO_FILE => "ext/Makefile" do |t|
|
|
Dir.chdir "ext" do
|
|
sh "make"
|
|
end
|
|
end
|
|
CLEAN.include LIB_FILE
|
|
|
|
directory "lib"
|
|
file LIB_FILE => [SO_FILE, "lib"] do |t|
|
|
copy t.source, t.name
|
|
end
|
|
|
|
Rake::TestTask.new do |t|
|
|
t.test_files = FileList["tests/test_*.rb"]
|
|
end
|
|
task test: [TEST_MODEL, LIB_FILE]
|
|
|
|
file TEST_MODEL do
|
|
Dir.chdir "../.." do
|
|
sh "./models/download-ggml-model.sh base.en"
|
|
end
|
|
end
|
|
|
|
TEST_MEMORY_VIEW = "tests/jfk_reader/jfk_reader.#{RbConfig::CONFIG['DLEXT']}"
|
|
file TEST_MEMORY_VIEW => "tests/jfk_reader/jfk_reader.c" do |t|
|
|
Dir.chdir "tests/jfk_reader" do
|
|
ruby "extconf.rb"
|
|
sh "make"
|
|
end
|
|
end
|
|
CLEAN.include "tests/jfk_reader/jfk_reader.{o,#{RbConfig::CONFIG['DLEXT']}}"
|
|
task test: TEST_MEMORY_VIEW
|