Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruby Bindings #500

Merged
merged 8 commits into from
Feb 15, 2023
Merged

Ruby Bindings #500

merged 8 commits into from
Feb 15, 2023

Conversation

taf2
Copy link
Contributor

@taf2 taf2 commented Feb 14, 2023

I did some work to build a ruby binding with the following interface:

require 'whisper'
params = Whisper::Params.new
whisper = Whisper::Context.new(File.join(File.dirname(__FILE__), 'models', 'ggml-base.en.bin'))

input = ARGV[0]
if input.nil?
  STDERR.puts "usage: t.rb your.wav"
  exit 1
end

whisper.transcribe(input, params) {|text|
  puts text.inspect
}

There are no doubt things that could be better and I was not sure how you felt bindings like this should integrate into the rest of the build system. The main thing I was not sure about is I copy when running extconf.rb the source file dependencies needed e.g. whisper.cpp etc...

@ggerganov
Copy link
Owner

That's great!
If you can provide a Github action for building/running the bindings I'll happily merge this.

@taf2
Copy link
Contributor Author

taf2 commented Feb 15, 2023

@ggerganov thanks, I think I added this into the right place in my most recent push - but I am also now thinking it'd be great to have a ruby gem for people to install easily via gem install whisper

One issue with how I am doing a cp to move the whisper.cpp files in extconf.rb is that if we package this into a rubygem those files will need to be in the ruby gem already... I'll work on a spec file now if you think it'd be hepful and maybe overcome this issue.

@ggerganov
Copy link
Owner

@taf2 I added a separate Ruby action based on your commit.

I'm not familiar with the ruby ecosystem. Whatever you think would be useful for other people is OK.
Let me know if this PR is OK to merge, or if you prefer to add the gem stuff before merging.

Regarding the copying of the sources - I don't fully understand why it is necessary. Would be useful to avoid it if possible.

@taf2
Copy link
Contributor Author

taf2 commented Feb 15, 2023

Agreed - yes I think this is a good starting place for ruby to be merged. I'm going to spend some more time today and hopefully not have to copy those files and maybe recruit some help too for getting it published to rubygems which i think would be ideal.

@ggerganov ggerganov merged commit b623ca4 into ggerganov:master Feb 15, 2023
rock3125 pushed a commit to rock3125/whisper.cpp that referenced this pull request Feb 21, 2023
* adding ruby bindings

* avoid adding these they are copied in via extconf.rb

* ignore these files here

* add definitions for boolean params

* initial transcribe for ruby

* use en model and transcribe jfk with assertion

* possibly this works for building ruby binding

* ci : try to add ruby workflow

---------

Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
anandijain pushed a commit to anandijain/whisper.cpp that referenced this pull request Apr 28, 2023
* adding ruby bindings

* avoid adding these they are copied in via extconf.rb

* ignore these files here

* add definitions for boolean params

* initial transcribe for ruby

* use en model and transcribe jfk with assertion

* possibly this works for building ruby binding

* ci : try to add ruby workflow

---------

Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
jacobwu-b pushed a commit to jacobwu-b/Transcriptify-by-whisper.cpp that referenced this pull request Oct 24, 2023
* adding ruby bindings

* avoid adding these they are copied in via extconf.rb

* ignore these files here

* add definitions for boolean params

* initial transcribe for ruby

* use en model and transcribe jfk with assertion

* possibly this works for building ruby binding

* ci : try to add ruby workflow

---------

Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
jacobwu-b pushed a commit to jacobwu-b/Transcriptify-by-whisper.cpp that referenced this pull request Oct 24, 2023
* adding ruby bindings

* avoid adding these they are copied in via extconf.rb

* ignore these files here

* add definitions for boolean params

* initial transcribe for ruby

* use en model and transcribe jfk with assertion

* possibly this works for building ruby binding

* ci : try to add ruby workflow

---------

Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
landtanin pushed a commit to landtanin/whisper.cpp that referenced this pull request Dec 16, 2023
* adding ruby bindings

* avoid adding these they are copied in via extconf.rb

* ignore these files here

* add definitions for boolean params

* initial transcribe for ruby

* use en model and transcribe jfk with assertion

* possibly this works for building ruby binding

* ci : try to add ruby workflow

---------

Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
iThalay pushed a commit to iThalay/whisper.cpp that referenced this pull request Sep 23, 2024
* adding ruby bindings

* avoid adding these they are copied in via extconf.rb

* ignore these files here

* add definitions for boolean params

* initial transcribe for ruby

* use en model and transcribe jfk with assertion

* possibly this works for building ruby binding

* ci : try to add ruby workflow

---------

Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants