whisper.cpp 0.3.3 → 0.3.4
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/.ruby-version +1 -1
- data/Gemfile.lock +2 -2
- data/ext/extconf.rb +39 -24
- data/lib/whisper/version.rb +1 -1
- data/lib/whisper.rb +21 -7
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9cd333686c64e91cb061ac8cf093e32bd76e977854ca84ee25c3929929c2f57
|
4
|
+
data.tar.gz: aff6dd2d092a9ad86f6f3c1453aaed13c42fc6f8d686886c86fcccc30667a15a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01cf0c815ec1e7630dc42787f424b521e2b172d67aa78662791c99d126bd4eed941d550ffe0601f88fec5bb6046332bbb0fcdb63eeaea1b3e538f6253768366d
|
7
|
+
data.tar.gz: 5e894cad714070459949b15cc7c527124ada408639dd5220cd14ba6bc92eafd2bde138f27683addf5d07bc2d193bc21a6d3813971a70881113e5e4696cf95023
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.3.
|
1
|
+
3.3.6
|
data/Gemfile.lock
CHANGED
data/ext/extconf.rb
CHANGED
@@ -43,26 +43,45 @@ unless Dir.exist?(whisper_dir)
|
|
43
43
|
abort "Failed to find or create the whisper.cpp directory at #{whisper_dir}"
|
44
44
|
end
|
45
45
|
|
46
|
-
# Now, proceed to build libwhispercpp.so
|
46
|
+
# Now, proceed to modify the Makefile and build libwhispercpp.so
|
47
47
|
Dir.chdir(whisper_dir) do
|
48
48
|
# Set environment variables for build settings
|
49
|
-
ENV['GGML_CUDA'] = '1' # Enable CUDA support
|
49
|
+
ENV['GGML_CUDA'] = '1' # Enable CUDA support if desired
|
50
50
|
|
51
|
-
|
51
|
+
# Modify the Makefile to add libwhispercpp.so target
|
52
|
+
makefile_path = File.join(Dir.pwd, 'Makefile')
|
53
|
+
|
54
|
+
makefile_content = File.read(makefile_path)
|
55
|
+
|
56
|
+
# Check if 'libwhispercpp.so' target is already defined
|
57
|
+
unless makefile_content.include?('libwhispercpp.so:')
|
58
|
+
# Append the new target at the end of the Makefile
|
59
|
+
new_content = <<~MAKEFILE
|
60
|
+
|
61
|
+
# Custom target for building libwhispercpp.so
|
62
|
+
libwhispercpp.so: $(OBJ_GGML) $(OBJ_WHISPER) $(OBJ_COMMON) $(OBJ_SDL) $(OBJ_WHISPER_EXTRA)
|
63
|
+
\t$(CXX) $(CXXFLAGS) -shared -fPIC -o $@ $^ $(LDFLAGS)
|
64
|
+
|
65
|
+
BUILD_TARGETS += libwhispercpp.so
|
66
|
+
MAKEFILE
|
67
|
+
|
68
|
+
makefile_content << new_content
|
69
|
+
|
70
|
+
# Write back the modified Makefile
|
71
|
+
File.open(makefile_path, 'w') do |f|
|
72
|
+
f.write(makefile_content)
|
73
|
+
end
|
52
74
|
|
53
|
-
|
54
|
-
|
55
|
-
|
75
|
+
puts "Modified Makefile to add libwhispercpp.so target."
|
76
|
+
else
|
77
|
+
puts "Makefile already contains libwhispercpp.so target."
|
56
78
|
end
|
57
79
|
|
58
|
-
|
59
|
-
gcc_command = 'g++ -shared -o libwhispercpp.so ' \
|
60
|
-
'-Wl,--whole-archive libwhisper.a -Wl,--no-whole-archive libggml.a ' \
|
61
|
-
'-L$( [ -d /opt/cuda ] && echo /opt/cuda/lib || echo /usr/local/cuda/lib ) ' \
|
62
|
-
'-lcuda -lcudart -lcublas -lc -lm -lstdc++'
|
80
|
+
puts "Building libwhispercpp.so with GGML_CUDA=#{ENV['GGML_CUDA']}..."
|
63
81
|
|
64
|
-
|
65
|
-
|
82
|
+
# Build libwhispercpp.so
|
83
|
+
unless system 'make clean && make -j libwhispercpp.so'
|
84
|
+
abort "Failed to build libwhispercpp.so"
|
66
85
|
end
|
67
86
|
|
68
87
|
# Verify that libwhispercpp.so was created
|
@@ -71,10 +90,11 @@ Dir.chdir(whisper_dir) do
|
|
71
90
|
abort "libwhispercpp.so not found after compilation"
|
72
91
|
end
|
73
92
|
|
74
|
-
# Copy the compiled library to the gem's
|
75
|
-
|
93
|
+
# Copy the compiled library to the gem's root directory
|
94
|
+
destination_lib = File.join(root_dir, 'libwhispercpp.so')
|
95
|
+
FileUtils.cp(source_lib, destination_lib)
|
76
96
|
|
77
|
-
puts "Copied libwhispercpp.so to #{
|
97
|
+
puts "Copied libwhispercpp.so to #{destination_lib}"
|
78
98
|
end
|
79
99
|
|
80
100
|
puts "Compilation completed."
|
@@ -82,9 +102,9 @@ puts "Compilation completed."
|
|
82
102
|
# Create a no-op Makefile to prevent RubyGems from attempting further compilation
|
83
103
|
makefile_content = <<~MAKEFILE
|
84
104
|
all:
|
85
|
-
|
105
|
+
\t@echo 'libwhispercpp.so already built.'
|
86
106
|
install:
|
87
|
-
|
107
|
+
\t@echo 'libwhispercpp.so already installed.'
|
88
108
|
MAKEFILE
|
89
109
|
|
90
110
|
File.open('Makefile', 'w') do |f|
|
@@ -93,15 +113,10 @@ end
|
|
93
113
|
|
94
114
|
puts "Created a no-op Makefile to prevent further compilation."
|
95
115
|
|
96
|
-
#
|
97
|
-
|
98
|
-
# Path to the cloned whisper.cpp directory
|
116
|
+
# Remove the cloned whisper.cpp directory
|
99
117
|
cloned_dir = whisper_dir
|
100
118
|
|
101
|
-
# Remove the cloned whisper.cpp directory
|
102
119
|
puts "Removing cloned whisper.cpp directory at #{cloned_dir}..."
|
103
120
|
FileUtils.rm_rf(cloned_dir)
|
104
|
-
|
105
121
|
puts "Removed cloned whisper.cpp directory."
|
106
122
|
|
107
|
-
|
data/lib/whisper/version.rb
CHANGED
data/lib/whisper.rb
CHANGED
@@ -26,7 +26,19 @@ module Whisper
|
|
26
26
|
:WHISPER_AHEADS_MEDIUM,
|
27
27
|
:WHISPER_AHEADS_LARGE_V1,
|
28
28
|
:WHISPER_AHEADS_LARGE_V2,
|
29
|
-
:WHISPER_AHEADS_LARGE_V3
|
29
|
+
:WHISPER_AHEADS_LARGE_V3,
|
30
|
+
:WHISPER_AHEADS_LARGE_V3_TURBO # Added new enum value
|
31
|
+
]
|
32
|
+
|
33
|
+
# Enums for grammar element type
|
34
|
+
enum :whisper_gretype, [
|
35
|
+
:WHISPER_GRETYPE_END, 0,
|
36
|
+
:WHISPER_GRETYPE_ALT,
|
37
|
+
:WHISPER_GRETYPE_RULE_REF,
|
38
|
+
:WHISPER_GRETYPE_CHAR,
|
39
|
+
:WHISPER_GRETYPE_CHAR_NOT,
|
40
|
+
:WHISPER_GRETYPE_CHAR_RNG_UPPER,
|
41
|
+
:WHISPER_GRETYPE_CHAR_ALT
|
30
42
|
]
|
31
43
|
|
32
44
|
# Enums for sampling strategy
|
@@ -93,7 +105,7 @@ module Whisper
|
|
93
105
|
|
94
106
|
# whisper_model_loader struct
|
95
107
|
#class WhisperModelLoader < FFI::Struct
|
96
|
-
# callback :read_callback, [:pointer, :pointer
|
108
|
+
# callback :read_callback, [:pointer, :pointer], :size_t
|
97
109
|
# callback :eof_callback, [:pointer], :bool
|
98
110
|
# callback :close_callback, [:pointer], :void
|
99
111
|
|
@@ -108,7 +120,7 @@ module Whisper
|
|
108
120
|
# whisper_grammar_element struct
|
109
121
|
class WhisperGrammarElement < FFI::Struct
|
110
122
|
layout(
|
111
|
-
:type, :
|
123
|
+
:type, :whisper_gretype,
|
112
124
|
:value, :uint32
|
113
125
|
)
|
114
126
|
end
|
@@ -131,7 +143,7 @@ module Whisper
|
|
131
143
|
# whisper_full_params struct
|
132
144
|
class WhisperFullParams < FFI::Struct
|
133
145
|
layout(
|
134
|
-
:strategy, :
|
146
|
+
:strategy, :whisper_sampling_strategy,
|
135
147
|
:n_threads, :int,
|
136
148
|
:n_max_text_ctx, :int,
|
137
149
|
:offset_ms, :int,
|
@@ -189,8 +201,10 @@ module Whisper
|
|
189
201
|
|
190
202
|
# Get default context params
|
191
203
|
attach_function :whisper_context_default_params, [], WhisperContextParams.by_value
|
204
|
+
attach_function :whisper_context_default_params_by_ref, [], :pointer
|
192
205
|
# Get default full params
|
193
|
-
attach_function :whisper_full_default_params, [:
|
206
|
+
attach_function :whisper_full_default_params, [:whisper_sampling_strategy], WhisperFullParams.by_value
|
207
|
+
attach_function :whisper_full_default_params_by_ref, [:whisper_sampling_strategy], :pointer
|
194
208
|
|
195
209
|
# Function Bindings
|
196
210
|
|
@@ -208,8 +222,8 @@ module Whisper
|
|
208
222
|
attach_function :whisper_init_state, [:pointer], :pointer
|
209
223
|
|
210
224
|
# OpenVINO functions
|
211
|
-
|
212
|
-
|
225
|
+
attach_function :whisper_ctx_init_openvino_encoder_with_state, [:pointer, :pointer, :string, :string, :string], :int
|
226
|
+
attach_function :whisper_ctx_init_openvino_encoder, [:pointer, :string, :string, :string], :int
|
213
227
|
|
214
228
|
# Free functions
|
215
229
|
attach_function :whisper_free, [:pointer], :void
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: whisper.cpp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Braulio Oliveira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -95,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
requirements: []
|
98
|
-
rubygems_version: 3.5.
|
98
|
+
rubygems_version: 3.5.22
|
99
99
|
signing_key:
|
100
100
|
specification_version: 4
|
101
101
|
summary: Ruby bindings for whisper.cpp
|