From 663444332c21dd3097ae6fe3b81ef7457e479c0c Mon Sep 17 00:00:00 2001 From: Todd Fisher Date: Sat, 25 Feb 2023 13:09:08 -0500 Subject: [PATCH] adding build files for rubygem whispercpp --- bindings/ruby/Rakefile | 27 ++++++++++++++++ bindings/ruby/lib/whispercpp.gemspec.erb | 40 ++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 bindings/ruby/Rakefile create mode 100644 bindings/ruby/lib/whispercpp.gemspec.erb diff --git a/bindings/ruby/Rakefile b/bindings/ruby/Rakefile new file mode 100644 index 0000000..5fe0fe6 --- /dev/null +++ b/bindings/ruby/Rakefile @@ -0,0 +1,27 @@ +require 'erb' +require 'rubygems/package' + +# Determine the current version of the software +if File.read('../../CMakeLists.txt') =~ /project.*\s*VERSION\s*(\d.+)\)/ + CURRENT_VERSION = $1 +else + CURRENT_VERSION = "0.0.0" +end + +desc 'Generate gem specification' +task :gemspec do + tspec = ERB.new(File.read(File.join(File.dirname(__FILE__),'lib','whispercpp.gemspec.erb'))) + File.open(File.join(File.dirname(__FILE__),'whispercpp.gemspec'),'wb') do|f| + f << tspec.result + end +end + +desc 'Build gem' +task :package => :gemspec do + spec_source = File.read File.join(File.dirname(__FILE__),'whispercpp.gemspec') + spec = nil + # see: http://gist.github.com/16215 + Thread.new { spec = eval("#{spec_source}") }.join + spec.validate + Gem::Package.build(spec) +end diff --git a/bindings/ruby/lib/whispercpp.gemspec.erb b/bindings/ruby/lib/whispercpp.gemspec.erb new file mode 100644 index 0000000..1ccba1a --- /dev/null +++ b/bindings/ruby/lib/whispercpp.gemspec.erb @@ -0,0 +1,40 @@ +Gem::Specification.new do |s| + s.name = "whispercpp" + s.authors = ["Georgi Gerganov", "Todd A. Fisher"] + s.version = '<%= CURRENT_VERSION %>' + s.date = '<%= Time.now.strftime("%Y-%m-%d") %>' + s.description = %q{High-performance inference of OpenAI's Whisper automatic speech recognition (ASR) model via Ruby} + s.email = 'todd.fisher@gmail.com' + s.extra_rdoc_files = ['../../LICENSE', '../../README.md'] + <% + files = %w(../../LICENSE ../../README.md Rakefile ext/extconf.rb) + + Dir["lib/**/**.rb"] + + Dir["ext/**/**.c"] + + Dir["ext/**/**.cpp"] + + Dir["ext/**/**.h"] + + if ENV['BINARY_PACKAGE'] # TODO: we could build binary packages + files += Dir['ext/**/*.{o,so,bundle}'] + end + %> + s.files = <%= files.inspect %> + + #### Load-time details + s.require_paths = ['lib','ext'] + s.summary = %q{Ruby whisper.cpp bindings} + s.test_files = <%= Dir['tests/**/**.rb'].inspect %> + <% unless ENV['BINARY_PACKAGE'] %> + s.extensions << 'ext/extconf.rb' + <% end %> + + #### Documentation and testing. + s.homepage = 'https://github.com/ggerganov/whisper.cpp' + s.rdoc_options = ['--main', '../../README.md'] + + <% if ENV['BINARY_PACKAGE'] %> + s.platform = Gem::Platform::CURRENT + <% else %> + s.platform = Gem::Platform::RUBY + <% end %> + s.licenses = ['MIT'] +end