ggerganov / whisper.cpp

Port of OpenAI's Whisper model in C/C++
MIT License
35.38k stars 3.61k forks source link

ruby: Installation problem #2483

Closed KitaitiMakoto closed 2 weeks ago

KitaitiMakoto commented 2 weeks ago

Hi,

whisper.cpp is great for me as a mac user and Ruby binding is also great as a Rubyist. Thank you so much.

I found gem install whispercpp fails on my machine and I investigated what happened. I needed some fixes for extconf.rb:

diff --git a/bindings/ruby/ext/extconf.rb b/bindings/ruby/ext/extconf.rb
index 5518928..aec1f0d 100644
--- a/bindings/ruby/ext/extconf.rb
+++ b/bindings/ruby/ext/extconf.rb
@@ -1,19 +1,20 @@
 require 'mkmf'
-system("cp #{File.join(File.dirname(__FILE__),'..','..','..','whisper.cpp')} .")
-system("cp #{File.join(File.dirname(__FILE__),'..','..','..','whisper.h')} .")
-system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml.h')} .")
-system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml.c')} .")
-system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml-impl.h')} .")
-system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml-aarch64.h')} .")
-system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml-aarch64.c')} .")
-system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml-alloc.h')} .")
-system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml-alloc.c')} .")
-system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml-backend-impl.h')} .")
-system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml-backend.h')} .")
-system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml-backend.cpp')} .")
-system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml-common.h')} .")
-system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml-quants.h')} .")
-system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml-quants.c')} .")
+system("cp #{File.join(File.dirname(__FILE__),'..','..','..','src','whisper.cpp')} .")
+system("cp #{File.join(File.dirname(__FILE__),'..','..','..','include','whisper.h')} .")
+system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml','include','ggml.h')} .")
+system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml','src','ggml.c')} .")
+system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml','src','ggml-impl.h')} .")
+system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml','src','ggml-aarch64.h')} .")
+system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml','src','ggml-aarch64.c')} .")
+system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml','include','ggml-alloc.h')} .")
+system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml','src','ggml-alloc.c')} .")
+system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml','src','ggml-backend-impl.h')} .")
+system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml','include','ggml-backend.h')} .")
+system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml','src','ggml-backend.cpp')} .")
+system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml','src','ggml-common.h')} .")
+system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml','src','ggml-quants.h')} .")
+system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml','src','ggml-quants.c')} .")
+system("cp #{File.join(File.dirname(__FILE__),'..','..','..','ggml','src','ggml-cpu-impl.h')} .")
 system("cp #{File.join(File.dirname(__FILE__),'..','..','..','examples','dr_wav.h')} .")

That's almost good, but one problem remains:

% uname -a
Darwin XXX 24.0.0 Darwin Kernel Version 24.0.0: Tue Sep 24 23:37:13 PDT 2024; root:xnu-11215.1.12~1/RELEASE_ARM64_T8112 arm64
% ruby -v
ruby 3.3.5 (2024-09-03 revision ef084cc8f4) [arm64-darwin23]
% ruby extconf.rb
creating Makefile
source files duplication - ggml-backend.{c,cpp}

Which should I choose C or C++ source file for ggml-backend? It seems C++ source is suitable because the compile fails if I remove ggml-backend.cpp. But, I'm not familiar with C and C++, so I'm not sure.

Thanks.

KitaitiMakoto commented 2 weeks ago

@ggerganov answered to this problem: https://github.com/ggerganov/whisper.cpp/discussions/507#discussioncomment-10949389 Thanks!

Will close this issue.

oriolgual commented 2 weeks ago

But aren’t those changes still requires @KitaitiMakoto ? I’m saying this because maybe the issue needs to be open?

KitaitiMakoto commented 2 weeks ago

@oriolgual The changes are just for quick investigation. Those are not good for creating Ruby binding.

I filed this issue for only one question about ggml-backend.cpp and ggml-backend.c. So, it completed its role.

Additionally, I created a pull request #2484, which includes fixes for this issue and more. So, I don't think reopening this issue is needed. But, I have no objection if you will file a tracking issue corresponding to the pull request or so.

oriolgual commented 2 weeks ago

@oriolgual The changes are just for quick investigation. Those are not good for creating Ruby binding.

I filed this issue for only one question about ggml-backend.cpp and ggml-backend.c. So, it completed its role.

Additionally, I created a pull request #2484, which includes fixes for this issue and more. So, I don't think reopening this issue is needed. But, I have no objection if you will file a tracking issue corresponding to the pull request or so.

No worries, I didn't see the PR. Great job and thanks for contributing with the fix!