ruby : refine HTTP cache feature (#3109)

* Use cache file when model host doesn't support if-modified-since

* Update gem date

* Revert "ruby : ignore "Downloading" output in test_log_suppress (#3106)"

This reverts commit edbd4cb7f5.
This commit is contained in:
KITAITI Makoto 2025-05-01 23:04:53 +09:00 committed by GitHub
parent 0778b6ff5f
commit 366082d072
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 4 additions and 13 deletions

View File

@ -55,6 +55,8 @@ module Whisper
when Net::HTTPNotModified when Net::HTTPNotModified
# noop # noop
when Net::HTTPOK when Net::HTTPOK
return if !response.key?("last-modified") && cache_path.exist?
download response download response
when Net::HTTPRedirection when Net::HTTPRedirection
request URI(response["location"]), headers request URI(response["location"]), headers

View File

@ -118,18 +118,7 @@ class TestWhisper < TestBase
dev = StringIO.new("") dev = StringIO.new("")
$stderr = dev $stderr = dev
Whisper::Context.new("base.en") Whisper::Context.new("base.en")
assert_empty dev.string
# Filter out any lines starting with "Downloading" or containing only dots.
# The reason for this is that I think the recent migration to Huggingface
# Xet might have changed the downloading behavior. There is now a redirect
# to a different URL, which causes the download to be retried even if the
# file is already downloaded.
# TODO(danbev) Remove this when a proper fix is in place.
filtered_output = dev.string.lines.reject do |line|
line.start_with?("Downloading") || line.strip =~ /^\.+$/
end.join
assert_empty filtered_output, "Expected no output, but got: #{filtered_output.inspect}"
ensure ensure
$stderr = stderr $stderr = stderr
end end

View File

@ -4,7 +4,7 @@ Gem::Specification.new do |s|
s.name = "whispercpp" s.name = "whispercpp"
s.authors = ["Georgi Gerganov", "Todd A. Fisher"] s.authors = ["Georgi Gerganov", "Todd A. Fisher"]
s.version = '1.3.2' s.version = '1.3.2'
s.date = '2025-04-25' s.date = '2025-05-01'
s.description = %q{High-performance inference of OpenAI's Whisper automatic speech recognition (ASR) model via Ruby} s.description = %q{High-performance inference of OpenAI's Whisper automatic speech recognition (ASR) model via Ruby}
s.email = 'todd.fisher@gmail.com' s.email = 'todd.fisher@gmail.com'
s.extra_rdoc_files = ['LICENSE', 'README.md'] s.extra_rdoc_files = ['LICENSE', 'README.md']