Skip to content

Commit 8ec52a3

Browse files
committed
Fix URI of CoreML models corresponding to quantized models
1 parent 37ca8b9 commit 8ec52a3

1 file changed

Lines changed: 8 additions & 16 deletions

File tree

  • bindings/ruby/lib/whisper/model

bindings/ruby/lib/whisper/model/uri.rb

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -216,22 +216,14 @@ def escaping(path)
216216
@pre_converted_models[name] = URI.new("https://huggingface.co/ggml-org/whisper-vad/resolve/main/ggml-#{name}.bin")
217217
end
218218

219-
@coreml_compiled_models = %w[
220-
tiny
221-
tiny.en
222-
base
223-
base.en
224-
small
225-
small.en
226-
medium
227-
medium.en
228-
large-v1
229-
large-v2
230-
large-v3
231-
large-v3-turbo
232-
].each_with_object({}) do |name, models|
233-
models[@pre_converted_models[name]] = ZipURI.new("https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-#{name}-encoder.mlmodelc.zip")
234-
end
219+
@coreml_compiled_models = @pre_converted_models.each_with_object({}) {|(name, uri), models|
220+
next if name.end_with?("-tdrz") || name.start_with?("silero-")
221+
222+
if matched = name.match(/\A(?<name>.*)-q\d_\d\z/)
223+
name = matched[:name]
224+
end
225+
models[uri] = ZipURI.new("https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-#{name}-encoder.mlmodelc.zip")
226+
}
235227

236228
class << self
237229
attr_reader :pre_converted_models, :coreml_compiled_models

0 commit comments

Comments
 (0)