whispercpp 1.3.2 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +6 -3
- data/README.md +71 -14
- data/Rakefile +20 -7
- data/ext/.gitignore +4 -6
- data/ext/dependencies.rb +36 -24
- data/ext/extconf.rb +1 -1
- data/ext/options.rb +48 -184
- data/ext/ruby_whisper.c +18 -0
- data/ext/ruby_whisper_context.c +43 -12
- data/ext/ruby_whisper_model.c +1 -1
- data/ext/ruby_whisper_params.c +4 -2
- data/ext/ruby_whisper_segment.c +81 -4
- data/ext/ruby_whisper_transcribe.cpp +13 -7
- data/ext/ruby_whisper_vad_params.c +1 -1
- data/ext/sources/CMakeLists.txt +5 -1
- data/ext/sources/bindings/javascript/package.json +1 -1
- data/ext/sources/examples/addon.node/__test__/whisper.spec.js +120 -24
- data/ext/sources/examples/addon.node/addon.cpp +150 -31
- data/ext/sources/examples/addon.node/index.js +3 -0
- data/ext/sources/examples/addon.node/vad-example.js +132 -0
- data/ext/sources/examples/bench/bench.cpp +3 -2
- data/ext/sources/examples/cli/cli.cpp +3 -2
- data/ext/sources/examples/command/command.cpp +32 -8
- data/ext/sources/examples/common-whisper.cpp +14 -7
- data/ext/sources/examples/lsp/lsp.cpp +2 -0
- data/ext/sources/examples/quantize/quantize.cpp +3 -0
- data/ext/sources/examples/server/CMakeLists.txt +3 -0
- data/ext/sources/examples/server/server.cpp +169 -22
- data/ext/sources/examples/stream/stream.cpp +6 -0
- data/ext/sources/examples/talk-llama/CMakeLists.txt +4 -1
- data/ext/sources/examples/talk-llama/llama-arch.cpp +171 -3
- data/ext/sources/examples/talk-llama/llama-arch.h +28 -1
- data/ext/sources/examples/talk-llama/llama-batch.cpp +741 -272
- data/ext/sources/examples/talk-llama/llama-batch.h +112 -54
- data/ext/sources/examples/talk-llama/llama-chat.cpp +30 -8
- data/ext/sources/examples/talk-llama/llama-chat.h +1 -0
- data/ext/sources/examples/talk-llama/llama-context.cpp +520 -351
- data/ext/sources/examples/talk-llama/llama-context.h +38 -17
- data/ext/sources/examples/talk-llama/llama-cparams.cpp +1 -1
- data/ext/sources/examples/talk-llama/llama-cparams.h +1 -1
- data/ext/sources/examples/talk-llama/llama-graph.cpp +447 -372
- data/ext/sources/examples/talk-llama/llama-graph.h +128 -58
- data/ext/sources/examples/talk-llama/llama-hparams.cpp +10 -2
- data/ext/sources/examples/talk-llama/llama-hparams.h +19 -2
- data/ext/sources/examples/talk-llama/llama-kv-cache-unified-iswa.cpp +279 -0
- data/ext/sources/examples/talk-llama/llama-kv-cache-unified-iswa.h +128 -0
- data/ext/sources/examples/talk-llama/llama-kv-cache-unified.cpp +1841 -0
- data/ext/sources/examples/talk-llama/llama-kv-cache-unified.h +303 -0
- data/ext/sources/examples/talk-llama/llama-kv-cache.h +14 -472
- data/ext/sources/examples/talk-llama/llama-kv-cells.h +86 -26
- data/ext/sources/examples/talk-llama/llama-memory-hybrid.cpp +246 -0
- data/ext/sources/examples/talk-llama/llama-memory-hybrid.h +138 -0
- data/ext/sources/examples/talk-llama/llama-memory-recurrent.cpp +1125 -0
- data/ext/sources/examples/talk-llama/llama-memory-recurrent.h +183 -0
- data/ext/sources/examples/talk-llama/llama-memory.cpp +58 -0
- data/ext/sources/examples/talk-llama/llama-memory.h +88 -4
- data/ext/sources/examples/talk-llama/llama-mmap.cpp +1 -1
- data/ext/sources/examples/talk-llama/llama-model-loader.cpp +42 -17
- data/ext/sources/examples/talk-llama/llama-model-saver.cpp +1 -0
- data/ext/sources/examples/talk-llama/llama-model.cpp +1863 -563
- data/ext/sources/examples/talk-llama/llama-model.h +27 -0
- data/ext/sources/examples/talk-llama/llama-quant.cpp +89 -6
- data/ext/sources/examples/talk-llama/llama-vocab.cpp +65 -28
- data/ext/sources/examples/talk-llama/llama-vocab.h +1 -0
- data/ext/sources/examples/talk-llama/llama.cpp +11 -7
- data/ext/sources/examples/talk-llama/llama.h +147 -40
- data/ext/sources/examples/talk-llama/talk-llama.cpp +2 -0
- data/ext/sources/examples/talk-llama/unicode.cpp +5 -0
- data/ext/sources/examples/vad-speech-segments/speech.cpp +6 -0
- data/ext/sources/examples/wchess/wchess.cmd/wchess.cmd.cpp +2 -0
- data/ext/sources/ggml/CMakeLists.txt +48 -3
- data/ext/sources/ggml/cmake/common.cmake +24 -0
- data/ext/sources/ggml/include/ggml-backend.h +1 -1
- data/ext/sources/ggml/include/ggml-cpu.h +2 -0
- data/ext/sources/ggml/include/ggml.h +144 -5
- data/ext/sources/ggml/src/CMakeLists.txt +82 -24
- data/ext/sources/ggml/src/ggml-backend-reg.cpp +5 -0
- data/ext/sources/ggml/src/ggml-backend.cpp +46 -23
- data/ext/sources/ggml/src/ggml-blas/CMakeLists.txt +3 -3
- data/ext/sources/ggml/src/ggml-cann/CMakeLists.txt +1 -0
- data/ext/sources/ggml/src/ggml-cann/common.h +6 -1
- data/ext/sources/ggml/src/ggml-cann/ggml-cann.cpp +33 -9
- data/ext/sources/ggml/src/ggml-common.h +4 -0
- data/ext/sources/ggml/src/ggml-cpu/CMakeLists.txt +133 -40
- data/ext/sources/ggml/src/ggml-cpu/amx/amx.cpp +1 -1
- data/ext/sources/ggml/src/ggml-cpu/amx/mmq.cpp +11 -10
- data/ext/sources/ggml/src/ggml-cpu/arch/arm/cpu-feats.cpp +94 -0
- data/ext/sources/ggml/src/ggml-cpu/arch/arm/quants.c +4114 -0
- data/ext/sources/ggml/src/ggml-cpu/arch/arm/repack.cpp +2163 -0
- data/ext/sources/ggml/src/ggml-cpu/arch/loongarch/quants.c +2639 -0
- data/ext/sources/ggml/src/ggml-cpu/arch/powerpc/cpu-feats.cpp +82 -0
- data/ext/sources/ggml/src/ggml-cpu/arch/powerpc/quants.c +2732 -0
- data/ext/sources/ggml/src/ggml-cpu/arch/riscv/quants.c +2069 -0
- data/ext/sources/ggml/src/ggml-cpu/arch/riscv/repack.cpp +397 -0
- data/ext/sources/ggml/src/ggml-cpu/arch/s390/quants.c +1300 -0
- data/ext/sources/ggml/src/ggml-cpu/arch/wasm/quants.c +1481 -0
- data/ext/sources/ggml/src/ggml-cpu/arch/x86/quants.c +4311 -0
- data/ext/sources/ggml/src/ggml-cpu/{ggml-cpu-aarch64.cpp → arch/x86/repack.cpp} +79 -3225
- data/ext/sources/ggml/src/ggml-cpu/arch-fallback.h +184 -0
- data/ext/sources/ggml/src/ggml-cpu/common.h +4 -3
- data/ext/sources/ggml/src/ggml-cpu/ggml-cpu-impl.h +16 -7
- data/ext/sources/ggml/src/ggml-cpu/ggml-cpu.c +146 -105
- data/ext/sources/ggml/src/ggml-cpu/ggml-cpu.cpp +12 -8
- data/ext/sources/ggml/src/ggml-cpu/{ggml-cpu-hbm.cpp → hbm.cpp} +1 -1
- data/ext/sources/ggml/src/ggml-cpu/kleidiai/kleidiai.cpp +1 -1
- data/ext/sources/ggml/src/ggml-cpu/llamafile/sgemm.cpp +58 -8
- data/ext/sources/ggml/src/ggml-cpu/llamafile/sgemm.h +5 -0
- data/ext/sources/ggml/src/ggml-cpu/ops.cpp +1057 -174
- data/ext/sources/ggml/src/ggml-cpu/ops.h +8 -0
- data/ext/sources/ggml/src/ggml-cpu/quants.c +1158 -0
- data/ext/sources/ggml/src/ggml-cpu/{ggml-cpu-quants.h → quants.h} +26 -0
- data/ext/sources/ggml/src/ggml-cpu/repack.cpp +1571 -0
- data/ext/sources/ggml/src/ggml-cpu/repack.h +98 -0
- data/ext/sources/ggml/src/ggml-cpu/simd-mappings.h +330 -38
- data/ext/sources/ggml/src/ggml-cpu/{ggml-cpu-traits.cpp → traits.cpp} +1 -1
- data/ext/sources/ggml/src/ggml-cpu/vec.cpp +111 -18
- data/ext/sources/ggml/src/ggml-cpu/vec.h +303 -94
- data/ext/sources/ggml/src/ggml-cuda/common.cuh +60 -37
- data/ext/sources/ggml/src/ggml-cuda/conv2d-dw.cu +161 -0
- data/ext/sources/ggml/src/ggml-cuda/conv2d-dw.cuh +5 -0
- data/ext/sources/ggml/src/ggml-cuda/conv2d-transpose.cu +91 -0
- data/ext/sources/ggml/src/ggml-cuda/conv2d-transpose.cuh +4 -0
- data/ext/sources/ggml/src/ggml-cuda/convert.cu +22 -0
- data/ext/sources/ggml/src/ggml-cuda/convert.cuh +5 -0
- data/ext/sources/ggml/src/ggml-cuda/fattn-common.cuh +2 -2
- data/ext/sources/ggml/src/ggml-cuda/fattn-mma-f16.cuh +5 -2
- data/ext/sources/ggml/src/ggml-cuda/fattn-wmma-f16.cu +4 -0
- data/ext/sources/ggml/src/ggml-cuda/ggml-cuda.cu +265 -123
- data/ext/sources/ggml/src/ggml-cuda/mean.cu +19 -0
- data/ext/sources/ggml/src/ggml-cuda/mean.cuh +3 -0
- data/ext/sources/ggml/src/ggml-cuda/mmv.cu +257 -87
- data/ext/sources/ggml/src/ggml-cuda/mmv.cuh +2 -3
- data/ext/sources/ggml/src/ggml-cuda/ssm-scan.cu +6 -4
- data/ext/sources/ggml/src/ggml-cuda/sumrows.cu +5 -18
- data/ext/sources/ggml/src/ggml-cuda/sumrows.cuh +0 -1
- data/ext/sources/ggml/src/ggml-cuda/unary.cu +89 -0
- data/ext/sources/ggml/src/ggml-cuda/unary.cuh +7 -0
- data/ext/sources/ggml/src/ggml-hip/CMakeLists.txt +4 -0
- data/ext/sources/ggml/src/ggml-impl.h +127 -183
- data/ext/sources/ggml/src/ggml-metal/CMakeLists.txt +11 -10
- data/ext/sources/ggml/src/ggml-metal/ggml-metal-impl.h +27 -0
- data/ext/sources/ggml/src/ggml-metal/ggml-metal.m +331 -49
- data/ext/sources/ggml/src/ggml-metal/ggml-metal.metal +564 -282
- data/ext/sources/ggml/src/ggml-musa/mudnn.cuh +2 -2
- data/ext/sources/ggml/src/ggml-opencl/CMakeLists.txt +14 -0
- data/ext/sources/ggml/src/ggml-opencl/ggml-opencl.cpp +1859 -489
- data/ext/sources/ggml/src/ggml-opencl/kernels/argsort.cl +86 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/concat.cl +109 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/div.cl +72 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/glu.cl +201 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/group_norm.cl +72 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/mul_mv_id_q4_0_f32_8x_flat.cl +283 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/pad.cl +30 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/repeat.cl +39 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/sigmoid.cl +29 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/sub.cl +72 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/sum_rows.cl +39 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/tanh.cl +63 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/tsembd.cl +48 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/upscale.cl +121 -0
- data/ext/sources/ggml/src/ggml-quants.c +6 -8
- data/ext/sources/ggml/src/ggml-rpc/ggml-rpc.cpp +18 -15
- data/ext/sources/ggml/src/ggml-sycl/CMakeLists.txt +3 -3
- data/ext/sources/ggml/src/ggml-sycl/binbcast.cpp +5 -6
- data/ext/sources/ggml/src/ggml-sycl/common.hpp +20 -48
- data/ext/sources/ggml/src/ggml-sycl/concat.cpp +28 -41
- data/ext/sources/ggml/src/ggml-sycl/conv.cpp +4 -10
- data/ext/sources/ggml/src/ggml-sycl/convert.cpp +117 -165
- data/ext/sources/ggml/src/ggml-sycl/cpy.cpp +192 -53
- data/ext/sources/ggml/src/ggml-sycl/dequantize.hpp +32 -0
- data/ext/sources/ggml/src/ggml-sycl/dmmv.cpp +49 -67
- data/ext/sources/ggml/src/ggml-sycl/dpct/helper.hpp +31 -1
- data/ext/sources/ggml/src/ggml-sycl/element_wise.cpp +648 -1039
- data/ext/sources/ggml/src/ggml-sycl/element_wise.hpp +18 -9
- data/ext/sources/ggml/src/ggml-sycl/gemm.hpp +3 -0
- data/ext/sources/ggml/src/ggml-sycl/getrows.cpp +8 -105
- data/ext/sources/ggml/src/ggml-sycl/ggml-sycl.cpp +238 -100
- data/ext/sources/ggml/src/ggml-sycl/gla.cpp +2 -2
- data/ext/sources/ggml/src/ggml-sycl/im2col.cpp +1 -1
- data/ext/sources/ggml/src/ggml-sycl/mmq.cpp +60 -80
- data/ext/sources/ggml/src/ggml-sycl/mmvq.cpp +158 -203
- data/ext/sources/ggml/src/ggml-sycl/norm.cpp +55 -74
- data/ext/sources/ggml/src/ggml-sycl/quants.hpp +38 -10
- data/ext/sources/ggml/src/ggml-sycl/rope.cpp +138 -27
- data/ext/sources/ggml/src/ggml-sycl/softmax.cpp +3 -3
- data/ext/sources/ggml/src/ggml-sycl/sycl_hw.cpp +3 -1
- data/ext/sources/ggml/src/ggml-sycl/sycl_hw.hpp +3 -0
- data/ext/sources/ggml/src/ggml-sycl/tsembd.cpp +3 -8
- data/ext/sources/ggml/src/ggml-sycl/vecdotq.hpp +108 -16
- data/ext/sources/ggml/src/ggml-sycl/wkv.cpp +12 -16
- data/ext/sources/ggml/src/ggml-vulkan/CMakeLists.txt +36 -32
- data/ext/sources/ggml/src/ggml-vulkan/ggml-vulkan.cpp +726 -282
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/CMakeLists.txt +4 -12
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/conv_transpose_1d.comp +98 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/geglu.comp +13 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/glu_head.comp +15 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/glu_main.comp +29 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/reglu.comp +9 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/rms_norm.comp +12 -3
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/swiglu.comp +9 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/vulkan-shaders-gen.cpp +10 -1
- data/ext/sources/ggml/src/ggml.c +328 -48
- data/ext/sources/ggml/src/ggml.cpp +26 -0
- data/ext/sources/ggml/src/gguf.cpp +24 -3
- data/ext/sources/include/whisper.h +2 -0
- data/ext/sources/src/CMakeLists.txt +2 -0
- data/ext/sources/src/coreml/whisper-compat.h +10 -0
- data/ext/sources/src/coreml/whisper-compat.m +35 -0
- data/ext/sources/src/coreml/whisper-decoder-impl.m +1 -0
- data/ext/sources/src/coreml/whisper-encoder-impl.m +1 -0
- data/ext/sources/src/whisper.cpp +218 -169
- data/extsources.rb +15 -9
- data/lib/whisper/context.rb +15 -0
- data/lib/whisper/model/uri.rb +56 -1
- data/lib/whisper/segment.rb +58 -0
- data/sig/whisper.rbs +68 -38
- data/{tests → test}/helper.rb +1 -12
- data/{tests → test}/test_model.rb +9 -0
- data/test/test_package.rb +51 -0
- data/test/test_segment.rb +146 -0
- data/{tests → test}/test_whisper.rb +70 -0
- data/whispercpp.gemspec +2 -3
- metadata +91 -43
- data/ext/sources/.dockerignore +0 -3
- data/ext/sources/.github/workflows/bindings-ruby.yml +0 -21
- data/ext/sources/ci/run.sh +0 -336
- data/ext/sources/close-issue.yml +0 -28
- data/ext/sources/examples/talk-llama/llama-kv-cache.cpp +0 -2739
- data/ext/sources/ggml/src/ggml-cpu/ggml-cpu-aarch64.h +0 -8
- data/ext/sources/ggml/src/ggml-cpu/ggml-cpu-quants.c +0 -13747
- data/tests/test_package.rb +0 -46
- data/tests/test_segment.rb +0 -74
- /data/ext/sources/ggml/src/ggml-cpu/{cpu-feats-x86.cpp → arch/x86/cpu-feats.cpp} +0 -0
- /data/ext/sources/ggml/src/ggml-cpu/{ggml-cpu-hbm.h → hbm.h} +0 -0
- /data/ext/sources/ggml/src/ggml-cpu/{ggml-cpu-traits.h → traits.h} +0 -0
- /data/{tests → test}/jfk_reader/.gitignore +0 -0
- /data/{tests → test}/jfk_reader/extconf.rb +0 -0
- /data/{tests → test}/jfk_reader/jfk_reader.c +0 -0
- /data/{tests → test}/test_callback.rb +0 -0
- /data/{tests → test}/test_error.rb +0 -0
- /data/{tests → test}/test_params.rb +0 -0
- /data/{tests → test}/test_vad.rb +0 -0
- /data/{tests → test}/test_vad_params.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3fdcc54e3e57a80116d06cd42636f910885f6e463387950414af3181ce956f6
|
4
|
+
data.tar.gz: de739103554359ce18d07666399670602fd1cbb62a0991352d32e9d625a4678e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1ffb0f1b2874cf5cc210df61eaa9f8b716639c05b6bd05cc3e94abea0fc46544b15b7ed2ee8a251014f56da89af029bfaa105f8d52ae93372e64018e7c93ebd
|
7
|
+
data.tar.gz: 591eae5d183c25a37911a233020f1aaa5826734b4259443bb4c9f5bc7d061ace06095504a5b7426f3c9a5e43eab29c5c630b6ad51d6b4dc3c315596fb1a37114
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -24,7 +24,21 @@ or,
|
|
24
24
|
|
25
25
|
$ gem install whispercpp -- --enable-ggml-cuda
|
26
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
|
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, for example:
|
28
|
+
|
29
|
+
Boolean options:
|
30
|
+
|
31
|
+
* `-DGGML_BLAS=1` -> `--enable-ggml-blas`
|
32
|
+
* `-DWHISER_COREML=OFF` -> `--disable-whisper-coreml`
|
33
|
+
|
34
|
+
Argument options:
|
35
|
+
|
36
|
+
* `-DGGML_CUDA_COMPRESSION_MODE=size` -> `--ggml-cuda-compression-mode=size`
|
37
|
+
|
38
|
+
Combination:
|
39
|
+
|
40
|
+
* `-DGGML_CUDA=1 -DCMAKE_CUDA_ARCHITECTURES="86"` -> `--enable-ggml-cuda --cmake_cuda-architectures="86"`
|
41
|
+
|
28
42
|
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
43
|
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
44
|
|
@@ -56,17 +70,6 @@ end
|
|
56
70
|
|
57
71
|
Some models are prepared up-front:
|
58
72
|
|
59
|
-
```ruby
|
60
|
-
base_en = Whisper::Model.pre_converted_models["base.en"]
|
61
|
-
whisper = Whisper::Context.new(base_en)
|
62
|
-
```
|
63
|
-
|
64
|
-
At first time you use a model, it is downloaded automatically. After that, downloaded cached file is used. To clear cache, call `#clear_cache`:
|
65
|
-
|
66
|
-
```ruby
|
67
|
-
Whisper::Model.pre_converted_models["base"].clear_cache
|
68
|
-
```
|
69
|
-
|
70
73
|
You also can use shorthand for pre-converted models:
|
71
74
|
|
72
75
|
```ruby
|
@@ -91,6 +94,19 @@ puts Whisper::Model.pre_converted_models.keys
|
|
91
94
|
# :
|
92
95
|
```
|
93
96
|
|
97
|
+
You can also retrieve each model:
|
98
|
+
|
99
|
+
```ruby
|
100
|
+
base_en = Whisper::Model.pre_converted_models["base.en"]
|
101
|
+
whisper = Whisper::Context.new(base_en)
|
102
|
+
```
|
103
|
+
|
104
|
+
At first time you use a model, it is downloaded automatically. After that, downloaded cached file is used. To clear cache, call `#clear_cache`:
|
105
|
+
|
106
|
+
```ruby
|
107
|
+
Whisper::Model.pre_converted_models["base"].clear_cache
|
108
|
+
```
|
109
|
+
|
94
110
|
You can also use local model files you prepared:
|
95
111
|
|
96
112
|
```ruby
|
@@ -146,9 +162,45 @@ Whisper::Params.new(
|
|
146
162
|
|
147
163
|
For details on VAD, see [whisper.cpp's README](https://github.com/ggml-org/whisper.cpp?tab=readme-ov-file#voice-activity-detection-vad).
|
148
164
|
|
165
|
+
### Output ###
|
166
|
+
|
167
|
+
whispercpp supports SRT and WebVTT output:
|
168
|
+
|
169
|
+
```ruby
|
170
|
+
puts whisper.transcribe("path/to/audio.wav", Whisper::Params.new).to_webvtt
|
171
|
+
# =>
|
172
|
+
WEBVTT
|
173
|
+
|
174
|
+
1
|
175
|
+
00:00:00.000 --> 00:00:03.860
|
176
|
+
My thought I have nobody by a beauty and will as you poured.
|
177
|
+
|
178
|
+
2
|
179
|
+
00:00:03.860 --> 00:00:09.840
|
180
|
+
Mr. Rochester is sub in that so-don't find simplest, and devoted about, to let might in
|
181
|
+
|
182
|
+
3
|
183
|
+
00:00:09.840 --> 00:00:09.940
|
184
|
+
a
|
185
|
+
|
186
|
+
```
|
187
|
+
|
188
|
+
You may call `#to_srt`, too
|
189
|
+
|
190
|
+
|
149
191
|
API
|
150
192
|
---
|
151
193
|
|
194
|
+
### Transcription ###
|
195
|
+
|
196
|
+
By default, `Whisper::Context#transcribe` works in a single thread. You can make it work in parallel by passing `n_processors` option:
|
197
|
+
|
198
|
+
```ruby
|
199
|
+
whisper.transcribe("path/to/audio.wav", params, n_processors: Etc.nprocessors)
|
200
|
+
```
|
201
|
+
|
202
|
+
Note that transcription occasionally might be low accuracy when it works in parallel.
|
203
|
+
|
152
204
|
### Segments ###
|
153
205
|
|
154
206
|
Once `Whisper::Context#transcribe` called, you can retrieve segments by `#each_segment`:
|
@@ -170,7 +222,7 @@ whisper
|
|
170
222
|
ed: format_time(segment.end_time),
|
171
223
|
text: segment.text
|
172
224
|
}
|
173
|
-
line << " (speaker turned)" if segment.
|
225
|
+
line << " (speaker turned)" if segment.speaker_turn_next?
|
174
226
|
puts line
|
175
227
|
end
|
176
228
|
|
@@ -186,7 +238,7 @@ params.on_new_segment do |segment|
|
|
186
238
|
ed: format_time(segment.end_time),
|
187
239
|
text: segment.text
|
188
240
|
}
|
189
|
-
line << " (speaker turned)" if segment.
|
241
|
+
line << " (speaker turned)" if segment.speaker_turn_next?
|
190
242
|
puts line
|
191
243
|
end
|
192
244
|
|
@@ -283,6 +335,11 @@ First call of `rake test` builds an extension and downloads a model for testing.
|
|
283
335
|
|
284
336
|
If something seems wrong on build, running `rake clean` solves some cases.
|
285
337
|
|
338
|
+
### Need help ###
|
339
|
+
|
340
|
+
* Windows support
|
341
|
+
* Refinement of C/C++ code, especially memory management
|
342
|
+
|
286
343
|
License
|
287
344
|
-------
|
288
345
|
|
data/Rakefile
CHANGED
@@ -67,17 +67,30 @@ file LIB_FILE => [SO_FILE, "lib"] do |t|
|
|
67
67
|
end
|
68
68
|
CLEAN.include LIB_FILE
|
69
69
|
|
70
|
-
Rake::TestTask.new
|
71
|
-
|
70
|
+
Rake::TestTask.new
|
71
|
+
|
72
|
+
TEST_FIXTURE_AUDIO = "test/fixtures/jfk.wav"
|
73
|
+
TEST_FIXTURE_AUDIO_SRC = File.expand_path(File.join(__dir__, "..", "..", "samples", "jfk.wav"))
|
74
|
+
TEST_FIXTURE_AUDIO_DIR = TEST_FIXTURE_AUDIO.pathmap("%d")
|
75
|
+
directory TEST_FIXTURE_AUDIO_DIR
|
76
|
+
if File.exist? TEST_FIXTURE_AUDIO_SRC
|
77
|
+
file TEST_FIXTURE_AUDIO => [TEST_FIXTURE_AUDIO_SRC, TEST_FIXTURE_AUDIO_DIR] do |t|
|
78
|
+
symlink t.source, t.name
|
79
|
+
end
|
80
|
+
else
|
81
|
+
require "open-uri"
|
82
|
+
file TEST_FIXTURE_AUDIO => TEST_FIXTURE_AUDIO_DIR do |t|
|
83
|
+
File.write t.name, URI("https://github.com/ggml-org/whisper.cpp/raw/refs/heads/master/samples/jfk.wav").read
|
84
|
+
end
|
72
85
|
end
|
73
86
|
|
74
|
-
TEST_MEMORY_VIEW = "
|
75
|
-
file TEST_MEMORY_VIEW => "
|
76
|
-
chdir "
|
87
|
+
TEST_MEMORY_VIEW = "test/jfk_reader/jfk_reader.#{RbConfig::CONFIG['DLEXT']}"
|
88
|
+
file TEST_MEMORY_VIEW => "test/jfk_reader/jfk_reader.c" do |t|
|
89
|
+
chdir "test/jfk_reader" do
|
77
90
|
ruby "extconf.rb"
|
78
91
|
sh "make"
|
79
92
|
end
|
80
93
|
end
|
81
|
-
CLEAN.include
|
94
|
+
CLEAN.include TEST_MEMORY_VIEW
|
82
95
|
|
83
|
-
task test: [LIB_FILE, TEST_MEMORY_VIEW]
|
96
|
+
task test: [LIB_FILE, TEST_MEMORY_VIEW, TEST_FIXTURE_AUDIO]
|
data/ext/.gitignore
CHANGED
data/ext/dependencies.rb
CHANGED
@@ -1,16 +1,32 @@
|
|
1
1
|
require "tsort"
|
2
2
|
|
3
3
|
class Dependencies
|
4
|
+
include TSort
|
5
|
+
|
4
6
|
def initialize(cmake, options)
|
5
7
|
@cmake = cmake
|
6
8
|
@options = options
|
9
|
+
@static_lib_shape = nil
|
10
|
+
@nodes = {}
|
11
|
+
@graph = Hash.new {|h, k| h[k] = []}
|
7
12
|
|
8
13
|
generate_dot
|
9
|
-
|
14
|
+
parse_dot
|
15
|
+
end
|
16
|
+
|
17
|
+
def libs
|
18
|
+
tsort.filter_map {|node|
|
19
|
+
label, shape = @nodes[node]
|
20
|
+
if shape == @static_lib_shape
|
21
|
+
label.gsub(/\\n\([^)]+\)/, '')
|
22
|
+
else
|
23
|
+
nil
|
24
|
+
end
|
25
|
+
}.reverse.collect {|lib| "lib#{lib}.a"}
|
10
26
|
end
|
11
27
|
|
12
28
|
def to_s
|
13
|
-
|
29
|
+
libs.join(" ")
|
14
30
|
end
|
15
31
|
|
16
32
|
private
|
@@ -20,42 +36,38 @@ class Dependencies
|
|
20
36
|
end
|
21
37
|
|
22
38
|
def generate_dot
|
23
|
-
|
39
|
+
args = ["-S", "sources", "-B", "build", "--graphviz", dot_path, "-D", "BUILD_SHARED_LIBS=OFF"]
|
40
|
+
args << @options.to_s unless @options.to_s.empty?
|
41
|
+
system @cmake, *args, exception: true
|
24
42
|
end
|
25
43
|
|
26
44
|
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
45
|
File.open(dot_path).each_line do |line|
|
40
46
|
case line
|
41
47
|
when /\[\s*label\s*=\s*"Static Library"\s*,\s*shape\s*=\s*(?<shape>\w+)\s*\]/
|
42
|
-
static_lib_shape = $~[:shape]
|
48
|
+
@static_lib_shape = $~[:shape]
|
43
49
|
when /\A\s*"(?<node>\w+)"\s*\[\s*label\s*=\s*"(?<label>\S+)"\s*,\s*shape\s*=\s*(?<shape>\w+)\s*\]\s*;\s*\z/
|
44
50
|
node = $~[:node]
|
45
51
|
label = $~[:label]
|
46
52
|
shape = $~[:shape]
|
47
|
-
nodes[node] = [label, shape]
|
53
|
+
@nodes[node] = [label, shape]
|
48
54
|
when /\A\s*"(?<depender>\w+)"\s*->\s*"(?<dependee>\w+)"/
|
49
55
|
depender = $~[:depender]
|
50
56
|
dependee = $~[:dependee]
|
51
|
-
|
52
|
-
depends[depender] << dependee
|
57
|
+
@graph[depender] << dependee
|
53
58
|
end
|
54
59
|
end
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
+
end
|
61
|
+
|
62
|
+
def tsort_each_node
|
63
|
+
@nodes.each_key do |node|
|
64
|
+
yield node
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def tsort_each_child(node)
|
69
|
+
@graph[node].each do |child|
|
70
|
+
yield child
|
71
|
+
end
|
60
72
|
end
|
61
73
|
end
|
data/ext/extconf.rb
CHANGED
data/ext/options.rb
CHANGED
@@ -1,25 +1,11 @@
|
|
1
1
|
class Options
|
2
|
-
def initialize
|
2
|
+
def initialize(cmake="cmake")
|
3
|
+
@cmake = cmake
|
3
4
|
@options = {}
|
4
|
-
@pending_options = []
|
5
|
-
@ignored_options = []
|
6
5
|
|
7
6
|
configure
|
8
7
|
end
|
9
8
|
|
10
|
-
def help
|
11
|
-
@options
|
12
|
-
.collect_concat {|name, (type, value)|
|
13
|
-
option = option_name(name)
|
14
|
-
if type == :bool
|
15
|
-
["--enable-#{option}", "--disable-#{option}"]
|
16
|
-
else
|
17
|
-
"--#{option}=#{type.upcase}"
|
18
|
-
end
|
19
|
-
}
|
20
|
-
.join($/)
|
21
|
-
end
|
22
|
-
|
23
9
|
def to_s
|
24
10
|
@options
|
25
11
|
.reject {|name, (type, value)| value.nil?}
|
@@ -32,190 +18,68 @@ class Options
|
|
32
18
|
|
33
19
|
output = nil
|
34
20
|
Dir.chdir __dir__ do
|
35
|
-
output =
|
21
|
+
output = `#{@cmake.shellescape} -S sources -B build -L`
|
36
22
|
end
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
def missing_options
|
51
|
-
cmake_options.collect {|name, type, value| name} -
|
52
|
-
@options.keys - @pending_options - @ignored_options
|
53
|
-
end
|
54
|
-
|
55
|
-
def extra_options
|
56
|
-
@options.keys + @pending_options + @ignored_options -
|
57
|
-
cmake_options.collect {|name, type, value| name}
|
23
|
+
@cmake_options = output.lines.drop_while {|line| line.chomp != "-- Cache values"}.drop(1)
|
24
|
+
.filter_map {|line|
|
25
|
+
option, value = line.chomp.split("=", 2)
|
26
|
+
name, type = option.split(":", 2)
|
27
|
+
[
|
28
|
+
name,
|
29
|
+
[
|
30
|
+
type,
|
31
|
+
type == "BOOL" ? value == "ON" : value
|
32
|
+
]
|
33
|
+
]
|
34
|
+
}.to_h
|
58
35
|
end
|
59
36
|
|
60
37
|
private
|
61
38
|
|
62
39
|
def configure
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
string "CMAKE_OSX_ARCHITECTURES"
|
69
|
-
ignored "CMAKE_OSX_DEPLOYMENT_TARGET"
|
70
|
-
string "CMAKE_OSX_SYSROOT"
|
71
|
-
filepath "FOUNDATION_LIBRARY"
|
72
|
-
bool "GGML_ACCELERATE"
|
73
|
-
bool "GGML_ALL_WARNINGS_3RD_PARTY"
|
74
|
-
bool "GGML_AMX_BF16"
|
75
|
-
bool "GGML_AMX_INT8"
|
76
|
-
bool "GGML_AMX_TILE"
|
77
|
-
bool "GGML_AVX"
|
78
|
-
bool "GGML_AVX2"
|
79
|
-
bool "GGML_AVX512"
|
80
|
-
bool "GGML_AVX512_BF16"
|
81
|
-
bool "GGML_AVX512_VBMI"
|
82
|
-
bool "GGML_AVX512_VNNI"
|
83
|
-
bool "GGML_AVX_VNNI"
|
84
|
-
ignored "GGML_BACKEND_DL"
|
85
|
-
ignored "GGML_BIN_INSTALL_DIR"
|
86
|
-
bool "GGML_BLAS"
|
87
|
-
string "GGML_BLAS_VENDOR"
|
88
|
-
bool "GGML_BMI2"
|
89
|
-
ignored "GGML_BUILD_EXAMPLES"
|
90
|
-
ignored "GGML_BUILD_TESTS"
|
91
|
-
bool "GGML_CCACHE"
|
92
|
-
filepath "GGML_CCACHE_FOUND"
|
93
|
-
bool "GGML_CPU"
|
94
|
-
bool "GGML_CPU_AARCH64"
|
95
|
-
ignored "GGML_CPU_ALL_VARIANTS"
|
96
|
-
string "GGML_CPU_ARM_ARCH"
|
97
|
-
bool "GGML_CPU_HBM"
|
98
|
-
bool "GGML_CPU_KLEIDIAI"
|
99
|
-
string "GGML_CPU_POWERPC_CPUTYPE"
|
100
|
-
bool "GGML_CUDA"
|
101
|
-
string "GGML_CUDA_COMPRESSION_MODE"
|
102
|
-
bool "GGML_CUDA_F16"
|
103
|
-
bool "GGML_CUDA_FA"
|
104
|
-
bool "GGML_CUDA_FA_ALL_QUANTS"
|
105
|
-
bool "GGML_CUDA_FORCE_CUBLAS"
|
106
|
-
bool "GGML_CUDA_FORCE_MMQ"
|
107
|
-
ignored "GGML_CUDA_GRAPHS"
|
108
|
-
bool "GGML_CUDA_NO_PEER_COPY"
|
109
|
-
bool "GGML_CUDA_NO_VMM"
|
110
|
-
string "GGML_CUDA_PEER_MAX_BATCH_SIZE"
|
111
|
-
bool "GGML_F16C"
|
112
|
-
bool "GGML_FMA"
|
113
|
-
bool "GGML_GPROF"
|
114
|
-
bool "GGML_HIP"
|
115
|
-
bool "GGML_HIP_GRAPHS"
|
116
|
-
bool "GGML_HIP_NO_VMM"
|
117
|
-
bool "GGML_HIP_ROCWMMA_FATTN"
|
118
|
-
ignored "GGML_INCLUDE_INSTALL_DIR"
|
119
|
-
bool "GGML_KOMPUTE"
|
120
|
-
bool "GGML_LASX"
|
121
|
-
ignored "GGML_LIB_INSTALL_DIR"
|
122
|
-
ignored "GGML_LLAMAFILE"
|
123
|
-
bool "GGML_LSX"
|
124
|
-
bool "GGML_LTO"
|
125
|
-
bool "GGML_METAL"
|
126
|
-
bool "GGML_METAL_EMBED_LIBRARY"
|
127
|
-
string "GGML_METAL_MACOSX_VERSION_MIN"
|
128
|
-
bool "GGML_METAL_NDEBUG"
|
129
|
-
bool "GGML_METAL_SHADER_DEBUG"
|
130
|
-
string "GGML_METAL_STD"
|
131
|
-
bool "GGML_METAL_USE_BF16"
|
132
|
-
bool "GGML_MUSA"
|
133
|
-
bool "GGML_NATIVE"
|
134
|
-
bool "GGML_OPENCL"
|
135
|
-
bool "GGML_OPENCL_EMBED_KERNELS"
|
136
|
-
bool "GGML_OPENCL_PROFILING"
|
137
|
-
string "GGML_OPENCL_TARGET_VERSION"
|
138
|
-
bool "GGML_OPENCL_USE_ADRENO_KERNELS"
|
139
|
-
bool "GGML_OPENMP"
|
140
|
-
bool "GGML_RPC"
|
141
|
-
bool "GGML_RVV"
|
142
|
-
bool "GGML_RV_ZFH"
|
143
|
-
pending "GGML_SCCACHE_FOUND"
|
144
|
-
string "GGML_SCHED_MAX_COPIES"
|
145
|
-
bool "GGML_SSE42"
|
146
|
-
ignored "GGML_STATIC"
|
147
|
-
bool "GGML_SYCL"
|
148
|
-
string "GGML_SYCL_DEVICE_ARCH"
|
149
|
-
bool "GGML_SYCL_F16"
|
150
|
-
bool "GGML_SYCL_GRAPH"
|
151
|
-
string "GGML_SYCL_TARGET"
|
152
|
-
bool "GGML_SYCL_DNN"
|
153
|
-
bool "GGML_VULKAN"
|
154
|
-
bool "GGML_VULKAN_CHECK_RESULTS"
|
155
|
-
bool "GGML_VULKAN_DEBUG"
|
156
|
-
bool "GGML_VULKAN_MEMORY_DEBUG"
|
157
|
-
bool "GGML_VULKAN_PERF"
|
158
|
-
ignored "GGML_VULKAN_RUN_TESTS"
|
159
|
-
filepath "GGML_VULKAN_SHADERS_GEN_TOOLCHAIN"
|
160
|
-
bool "GGML_VULKAN_SHADER_DEBUG_INFO"
|
161
|
-
pending "GGML_VULKAN_VALIDATE"
|
162
|
-
bool "GGML_VXE"
|
163
|
-
bool "GGML_XTHEADVECTOR"
|
164
|
-
filepath "GIT_EXE"
|
165
|
-
filepath "MATH_LIBRARY"
|
166
|
-
filepath "METALKIT_FRAMEWORK"
|
167
|
-
filepath "METAL_FRAMEWORK"
|
168
|
-
bool "WHISPER_ALL_WARNINGS"
|
169
|
-
bool "WHISPER_ALL_WARNINGS_3RD_PARTY"
|
170
|
-
ignored "WHISPER_BIN_INSTALL_DIR"
|
171
|
-
ignored "WHISPER_BUILD_EXAMPLES"
|
172
|
-
ignored "WHISPER_BUILD_SERVER"
|
173
|
-
ignored"WHISPER_BUILD_TESTS"
|
174
|
-
bool "WHISPER_COREML"
|
175
|
-
bool "WHISPER_COREML_ALLOW_FALLBACK"
|
176
|
-
ignored "WHISPER_CURL"
|
177
|
-
bool "WHISPER_FATAL_WARNINGS"
|
178
|
-
ignored "WHISPER_FFMPEG"
|
179
|
-
ignored "WHISPER_INCLUDE_INSTALL_DIR"
|
180
|
-
ignored "WHISPER_LIB_INSTALL_DIR"
|
181
|
-
bool "WHISPER_OPENVINO"
|
182
|
-
bool "WHISPER_SANITIZE_ADDRESS"
|
183
|
-
bool "WHISPER_SANITIZE_THREAD"
|
184
|
-
bool "WHISPER_SANITIZE_UNDEFINED"
|
185
|
-
ignored "WHISPER_SDL2"
|
186
|
-
pending "WHISPER_USE_SYSTEM_GGML"
|
187
|
-
end
|
188
|
-
|
189
|
-
def option_name(name)
|
190
|
-
name.downcase.gsub("_", "-")
|
191
|
-
end
|
40
|
+
cmake_options.each_pair do |name, (type, default_value)|
|
41
|
+
option = option_name(name)
|
42
|
+
value = type == "BOOL" ? enable_config(option) : arg_config("--#{option}")
|
43
|
+
@options[name] = [type, value]
|
44
|
+
end
|
192
45
|
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
@options[name] = [:bool, value]
|
46
|
+
configure_accelerate
|
47
|
+
configure_metal
|
48
|
+
configure_coreml
|
197
49
|
end
|
198
50
|
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
51
|
+
# See ggml/src/ggml-cpu/CMakeLists.txt
|
52
|
+
def configure_accelerate
|
53
|
+
if RUBY_PLATFORM.match?(/darwin/) && enabled?("GGML_ACCELERATE")
|
54
|
+
$LDFLAGS << " -framework Accelerate"
|
55
|
+
end
|
204
56
|
end
|
205
57
|
|
206
|
-
|
207
|
-
|
58
|
+
# See ggml/src/ggml-metal/CMakeLists.txt
|
59
|
+
def configure_metal
|
60
|
+
$LDFLAGS << " -framework Foundation -framework Metal -framework MetalKit" if enabled?("GGML_METAL")
|
208
61
|
end
|
209
62
|
|
210
|
-
|
211
|
-
|
63
|
+
# See src/CmakeLists.txt
|
64
|
+
def configure_coreml
|
65
|
+
if enabled?("WHISPER_COREML")
|
66
|
+
$LDFLAGS << " -framework Foundation -framework CoreML"
|
67
|
+
$defs << "-DRUBY_WHISPER_USE_COREML"
|
68
|
+
end
|
212
69
|
end
|
213
70
|
|
214
|
-
def
|
215
|
-
|
71
|
+
def option_name(name)
|
72
|
+
name.downcase.gsub("_", "-")
|
216
73
|
end
|
217
74
|
|
218
|
-
def
|
219
|
-
|
75
|
+
def enabled?(option)
|
76
|
+
op = @options[option]
|
77
|
+
raise "Option not exist: #{option}" unless op
|
78
|
+
raise "Option not boolean: #{option}(#{op[0]})" unless op[0] == "BOOL"
|
79
|
+
if op[1].nil?
|
80
|
+
cmake_options[option][1]
|
81
|
+
else
|
82
|
+
op[1]
|
83
|
+
end
|
220
84
|
end
|
221
85
|
end
|
data/ext/ruby_whisper.c
CHANGED
@@ -22,6 +22,9 @@ ID id_new;
|
|
22
22
|
ID id_to_path;
|
23
23
|
ID id_URI;
|
24
24
|
ID id_pre_converted_models;
|
25
|
+
ID id_coreml_compiled_models;
|
26
|
+
ID id_cache;
|
27
|
+
ID id_n_processors;
|
25
28
|
|
26
29
|
static bool is_log_callback_finalized = false;
|
27
30
|
|
@@ -83,6 +86,14 @@ static VALUE ruby_whisper_s_lang_str_full(VALUE self, VALUE id) {
|
|
83
86
|
return rb_str_new2(str_full);
|
84
87
|
}
|
85
88
|
|
89
|
+
/*
|
90
|
+
* call-seq:
|
91
|
+
* system_info_str -> String
|
92
|
+
*/
|
93
|
+
static VALUE ruby_whisper_s_system_info_str(VALUE self) {
|
94
|
+
return rb_str_new2(whisper_print_system_info());
|
95
|
+
}
|
96
|
+
|
86
97
|
static VALUE ruby_whisper_s_finalize_log_callback(VALUE self, VALUE id) {
|
87
98
|
is_log_callback_finalized = true;
|
88
99
|
return Qnil;
|
@@ -130,10 +141,14 @@ void Init_whisper() {
|
|
130
141
|
id_to_path = rb_intern("to_path");
|
131
142
|
id_URI = rb_intern("URI");
|
132
143
|
id_pre_converted_models = rb_intern("pre_converted_models");
|
144
|
+
id_coreml_compiled_models = rb_intern("coreml_compiled_models");
|
145
|
+
id_cache = rb_intern("cache");
|
146
|
+
id_n_processors = rb_intern("n_processors");
|
133
147
|
|
134
148
|
mWhisper = rb_define_module("Whisper");
|
135
149
|
mVAD = rb_define_module_under(mWhisper, "VAD");
|
136
150
|
|
151
|
+
rb_define_const(mWhisper, "VERSION", rb_str_new2(whisper_version()));
|
137
152
|
rb_define_const(mWhisper, "LOG_LEVEL_NONE", INT2NUM(GGML_LOG_LEVEL_NONE));
|
138
153
|
rb_define_const(mWhisper, "LOG_LEVEL_INFO", INT2NUM(GGML_LOG_LEVEL_INFO));
|
139
154
|
rb_define_const(mWhisper, "LOG_LEVEL_WARN", INT2NUM(GGML_LOG_LEVEL_WARN));
|
@@ -145,6 +160,7 @@ void Init_whisper() {
|
|
145
160
|
rb_define_singleton_method(mWhisper, "lang_id", ruby_whisper_s_lang_id, 1);
|
146
161
|
rb_define_singleton_method(mWhisper, "lang_str", ruby_whisper_s_lang_str, 1);
|
147
162
|
rb_define_singleton_method(mWhisper, "lang_str_full", ruby_whisper_s_lang_str_full, 1);
|
163
|
+
rb_define_singleton_method(mWhisper, "system_info_str", ruby_whisper_s_system_info_str, 0);
|
148
164
|
rb_define_singleton_method(mWhisper, "log_set", ruby_whisper_s_log_set, 2);
|
149
165
|
rb_define_private_method(rb_singleton_class(mWhisper), "finalize_log_callback", ruby_whisper_s_finalize_log_callback, 1);
|
150
166
|
|
@@ -155,5 +171,7 @@ void Init_whisper() {
|
|
155
171
|
init_ruby_whisper_model(&mWhisper);
|
156
172
|
init_ruby_whisper_vad_params(&mVAD);
|
157
173
|
|
174
|
+
rb_require("whisper/context");
|
175
|
+
rb_require("whisper/segment");
|
158
176
|
rb_require("whisper/model/uri");
|
159
177
|
}
|