Skip to content

Commit 1167dc4

Browse files
committed
Merge remote-tracking branch 'ggerganov/master'
* ggerganov/master: (25 commits) examples : add HEAPU8 to exported runtime methods (ggml-org#3062) ruby : make Ruby bindings installed with build options (ggml-org#3056) whisper : add no_context parameter to whisper_params (ggml-org#3045) examples : add FFmpeg v7.0 support to ffmpeg-transcode.cpp (ggml-org#3038) ruby: use CMake in build process (ggml-org#3043) docs : update README.md to note newer nvidia gpus (ggml-org#3031) addon.node : support max_context api for addon.node (ggml-org#3025) whisper : reduce delta_min from 1000ms to 100ms (ggml-org#3028) docs : document how to use 'WHISPER_FFMPEG' build option (ggml-org#3029) docs : fix README.md (ggml-org#3024) xcf : use check for visionos build version (ggml-org#3021) ruby : fix types of arguments for rb_get_kwargs in ruby_whisper_params.c (ggml-org#3022) ruby : Update uri.rb (ggml-org#3016) models : fix dead link to models in readme (ggml-org#3006) ruby : change homepage URI in Ruby gemspec (ggml-org#3007) tests : add script to benchmark whisper.cpp on LibriSpeech corpus (ggml-org#2999) whisper : fix "bench-all outputs an invalid result on larger models" (ggml-org#3002) rename : ggerganov -> ggml-org (ggml-org#3005) examples : update server.py to match github pages app [no ci] (ggml-org#3004) whisper.wasm : fix unknown language issue (ggml-org#3000) ...
2 parents 439d97e + 3a88f1e commit 1167dc4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+15160
-11904
lines changed

.github/workflows/bindings-ruby.yml

Lines changed: 5 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,11 @@
11
name: Bindings Tests (Ruby)
2+
23
on:
34
push:
4-
paths:
5-
- bindings/ruby/**
6-
- src/**/*.c
7-
- src/**/*.cpp
8-
- src/**/*.h
9-
- src/**/*.m
10-
- src/**/*.metal
11-
- include/**/*.c
12-
- include/**/*.cpp
13-
- include/**/*.h
14-
- include/**/*.m
15-
- include/**/*.metal
16-
- ggml/**/*.c
17-
- ggml/**/*.cpp
18-
- ggml/**/*.h
19-
- ggml/**/*.m
20-
- ggml/**/*.metal
21-
- scripts/get-flags.mk
22-
- examples/common.h
23-
- examples/common.cpp
24-
- examples/common-whisper.h
25-
- examples/common-whisper.cpp
26-
- examples/stb_vorbis.c
27-
- examples/miniaudio.h
5+
branches:
6+
- master
287
pull_request:
29-
paths:
30-
- bindings/ruby/**
31-
- src/**/*.c
32-
- src/**/*.cpp
33-
- src/**/*.h
34-
- src/**/*.m
35-
- src/**/*.metal
36-
- include/**/*.c
37-
- include/**/*.cpp
38-
- include/**/*.h
39-
- include/**/*.m
40-
- include/**/*.metal
41-
- ggml/**/*.c
42-
- ggml/**/*.cpp
43-
- ggml/**/*.h
44-
- ggml/**/*.m
45-
- ggml/**/*.metal
46-
- scripts/get-flags.mk
47-
- examples/common.h
48-
- examples/common.cpp
49-
- examples/common-whisper.h
50-
- examples/common-whisper.cpp
51-
- examples/stb_vorbis.c
52-
- examples/miniaudio.h
8+
types: [opened, synchronize, reopened]
539

5410
jobs:
5511
ubuntu-22:
@@ -60,6 +16,6 @@ jobs:
6016
steps:
6117
- uses: ruby/setup-ruby@v1
6218
with:
63-
ruby-version: '3.1'
19+
ruby-version: '3.2'
6420
- uses: actions/checkout@v4
6521
- run: rake test

README.md

Lines changed: 96 additions & 35 deletions
Large diffs are not rendered by default.

bindings/go/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func main() {
5151
In order to build, you need to have the Go compiler installed. You can get it from [here](https://golang.org/dl/). Run the tests with:
5252

5353
```bash
54-
git clone https://github.com/ggerganov/whisper.cpp.git
54+
git clone https://github.com/ggml-org/whisper.cpp.git
5555
cd whisper.cpp/bindings/go
5656
make test
5757
```
@@ -98,7 +98,7 @@ The API Documentation:
9898

9999
Getting help:
100100

101-
* Follow the discussion for the go bindings [here](https://github.com/ggerganov/whisper.cpp/discussions/312)
101+
* Follow the discussion for the go bindings [here](https://github.com/ggml-org/whisper.cpp/discussions/312)
102102

103103
## License
104104

bindings/go/doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
github.com/ggerganov/whisper.cpp/bindings/go
2+
github.com/ggml-org/whisper.cpp/bindings/go
33
provides a speech-to-text service bindings for the Go programming language.
44
*/
55
package whisper

bindings/java/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ public class Example {
3131
var whisperParams = whisper.getFullDefaultParams(WhisperSamplingStrategy.WHISPER_SAMPLING_GREEDY);
3232
// custom configuration if required
3333
whisperParams.temperature_inc = 0f;
34-
34+
3535
var samples = readAudio(); // divide each value by 32767.0f
3636
whisper.fullTranscribe(whisperParams, samples);
37-
37+
3838
int segmentCount = whisper.getTextSegmentCount(context);
3939
for (int i = 0; i < segmentCount; i++) {
4040
String text = whisper.getTextSegment(context, i);
@@ -52,7 +52,7 @@ public class Example {
5252
In order to build, you need to have the JDK 8 or higher installed. Run the tests with:
5353

5454
```bash
55-
git clone https://github.com/ggerganov/whisper.cpp.git
55+
git clone https://github.com/ggml-org/whisper.cpp.git
5656
cd whisper.cpp/bindings/java
5757

5858
./gradlew build

bindings/ruby/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
LICENSE
22
pkg/
33
lib/whisper.*
4+
ext/sources/*
5+
!ext/sources/CMakeGraphVizOptions.cmake
6+
ext/mkmf.log

bindings/ruby/README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@ If bundler is not being used to manage dependencies, install the gem by executin
1616

1717
$ gem install whispercpp
1818

19+
You can pass build options for whisper.cpp, for instance:
20+
21+
$ bundle config build.whispercpp --enable-ggml-cuda
22+
23+
or,
24+
25+
$ gem install whispercpp -- --enable-ggml-cuda
26+
27+
See whisper.cpp's [README](https://github.com/ggml-org/whisper.cpp/blob/master/README.md) for available options. You need convert options present the README to Ruby-style options.
28+
For boolean options like `GGML_CUDA`, the README says `-DGGML_CUDA=1`. You need strip `-D`, prepend `--enable-` for `1` or `ON` (`--disable-` for `0` or `OFF`) and make it kebab-case: `--enable-ggml-cuda`.
29+
For options which require arguments like `CMAKE_CUDA_ARCHITECTURES`, the README says `-DCMAKE_CUDA_ARCHITECTURES="86"`. You need strip `-D`, prepend `--`, make it kebab-case, append `=` and append argument: `--cmake-cuda-architectures="86"`.
30+
1931
Usage
2032
-----
2133

@@ -228,7 +240,7 @@ The second argument `samples` may be an array, an object with `length` and `each
228240
Development
229241
-----------
230242

231-
% git clone https://github.com/ggerganov/whisper.cpp.git
243+
% git clone https://github.com/ggml-org/whisper.cpp.git
232244
% cd whisper.cpp/bindings/ruby
233245
% rake test
234246

@@ -241,5 +253,5 @@ License
241253

242254
The same to [whisper.cpp][].
243255

244-
[whisper.cpp]: https://github.com/ggerganov/whisper.cpp
245-
[models]: https://github.com/ggerganov/whisper.cpp/tree/master/models
256+
[whisper.cpp]: https://github.com/ggml-org/whisper.cpp
257+
[models]: https://github.com/ggml-org/whisper.cpp/tree/master/models

bindings/ruby/Rakefile

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@ require "bundler/gem_tasks"
33
require "rake/testtask"
44
require_relative "extsources"
55

6+
SOURCES_DIR = "ext/sources"
7+
68
SOURCES = FileList[]
79

810
EXTSOURCES.each do |src|
911
basename = src.pathmap("%f")
10-
dest = basename == "LICENSE" ? basename : src.pathmap("%{../..,ext}p")
12+
dest = basename == "LICENSE" ? basename
13+
: src.pathmap("%{\\.\\./\\.\\.,#{SOURCES_DIR}}p")
14+
.pathmap("%{\\.\\./javascript,#{SOURCES_DIR}/bindings/javascript}p")
1115
dir = dest.pathmap("%d")
1216
file src
1317
directory dir
@@ -18,7 +22,6 @@ EXTSOURCES.each do |src|
1822
end
1923

2024
CLEAN.include SOURCES
21-
CLEAN.include FileList["ext/**/*.o", "ext/**/*.metal", "ext/**/*.tmp", "ext/whisper.{so,bundle,dll}"]
2225

2326
SRC = FileList["ext/*.{c,cpp,h}"]
2427

@@ -36,6 +39,20 @@ file "ext/Makefile" => SRC + ["ext/extconf.rb"] + SOURCES do |t|
3639
ruby "extconf.rb"
3740
end
3841
end
42+
if File.exist? "ext/Makefile"
43+
task :make_clean do
44+
cd "ext" do
45+
sh "make", "clean"
46+
end
47+
end
48+
task clean: :make_clean
49+
task :make_distclean do
50+
cd "ext" do
51+
sh "make", "distclean"
52+
end
53+
end
54+
task clobber: :make_distclean
55+
end
3956

4057
file SO_FILE => "ext/Makefile" do |t|
4158
chdir "ext" do

bindings/ruby/ext/cpu.mk

Lines changed: 0 additions & 11 deletions
This file was deleted.

bindings/ruby/ext/dependencies.rb

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
require "tsort"
2+
3+
class Dependencies
4+
def initialize(cmake, options)
5+
@cmake = cmake
6+
@options = options
7+
8+
generate_dot
9+
@libs = parse_dot
10+
end
11+
12+
def to_s
13+
@libs.join(" ")
14+
end
15+
16+
private
17+
18+
def dot_path
19+
File.join(__dir__, "build", "whisper.cpp.dot")
20+
end
21+
22+
def generate_dot
23+
system @cmake, "-S", "sources", "-B", "build", "--graphviz", dot_path, "-D", "BUILD_SHARED_LIBS=OFF", @options.to_s, exception: true
24+
end
25+
26+
def parse_dot
27+
static_lib_shape = nil
28+
nodes = {}
29+
depends = Hash.new {|h, k| h[k] = []}
30+
31+
class << depends
32+
include TSort
33+
alias tsort_each_node each_key
34+
def tsort_each_child(node, &block)
35+
fetch(node, []).each(&block)
36+
end
37+
end
38+
39+
File.open(dot_path).each_line do |line|
40+
case line
41+
when /\[\s*label\s*=\s*"Static Library"\s*,\s*shape\s*=\s*(?<shape>\w+)\s*\]/
42+
static_lib_shape = $~[:shape]
43+
when /\A\s*"(?<node>\w+)"\s*\[\s*label\s*=\s*"(?<label>\S+)"\s*,\s*shape\s*=\s*(?<shape>\w+)\s*\]\s*;\s*\z/
44+
node = $~[:node]
45+
label = $~[:label]
46+
shape = $~[:shape]
47+
nodes[node] = [label, shape]
48+
when /\A\s*"(?<depender>\w+)"\s*->\s*"(?<dependee>\w+)"/
49+
depender = $~[:depender]
50+
dependee = $~[:dependee]
51+
depends[depender] ||= []
52+
depends[depender] << dependee
53+
end
54+
end
55+
depends.tsort.filter_map {|node|
56+
label, shape = nodes[node]
57+
shape == static_lib_shape ? label : nil
58+
}.collect {|lib| "lib#{lib}.a"}
59+
.reverse
60+
end
61+
end

0 commit comments

Comments
 (0)