whisper.cpp 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 561b7b824c1f631537d681fb1e5a1eafe20546a8468705ecd2ba3989e0062c69
4
- data.tar.gz: e047a8ab099358095100a55cd30aca398bbe8b8c4c55cfb0713cdf33e87d2e1a
3
+ metadata.gz: 3d1b91cc9ac6e7682429f261d3e9b283c4c34ef246a2e88d07f1c294d145d1f4
4
+ data.tar.gz: be2a0ff1c4eda542685c209e6c64b7f3f3f902c4353534747922ea89c42ef24d
5
5
  SHA512:
6
- metadata.gz: 80c60958d31df322ac570c97ca6d758278f8711d9bfff371be34e8159ffcadc2facf149aa4c7b55de49a2d2d8812b570d0ddd68e543172301f930fe494a4243b
7
- data.tar.gz: 02fd686ff1857adf234c53fa0719035e797a82bed4b165e54004c0b7c903728eb7d8c44273b3f46e6ff21a32df44e29986092b72ccfd853324749e639fa303ed
6
+ metadata.gz: c992abd9e3e9b48d6b31cfa6489b5b09489781d251c2d3ca24d4932fca579b7d19b7483a1d72aefe77ac0655d5d5af19708bf6342cf6e5d4922d3663b1244acc
7
+ data.tar.gz: 8890fa1e7653f8690c3686a7751e597958c06adfaa3a0b3a3e74c947920f1da2014ada7eebe4fd78e85cc2a74fe235b244c43817937072ffe3b7c75792567ec1
data/lib/whisper/model.rb CHANGED
@@ -8,6 +8,7 @@ module Whisper
8
8
  def initialize(model_path)
9
9
  @model_path = model_path
10
10
  @ctx = nil
11
+ init_whisper_context
11
12
  end
12
13
 
13
14
  def transcribe_from_file(audio_file_path, format: 'plaintext', **params)
@@ -17,8 +18,6 @@ module Whisper
17
18
  end
18
19
 
19
20
  def transcribe_from_audio_data(audio_data, format: 'plaintext', **params)
20
- init_whisper_context(params)
21
-
22
21
  # Prepare full params
23
22
  full_params = default_full_params(params)
24
23
 
@@ -49,19 +48,13 @@ module Whisper
49
48
 
50
49
  private
51
50
 
52
- def init_whisper_context(params)
51
+ def init_whisper_context params = {}
53
52
  return unless @ctx.nil?
54
53
 
55
54
  ctx_params = Whisper.whisper_context_default_params
56
55
 
57
- # Set user-provided context params
58
- user_ctx_params = params.fetch(:context_params, {})
59
- user_ctx_params.each do |key, value|
60
- if ctx_params.members.include?(field)
61
- ctx_params[key] = value
62
- else
63
- warn "Unknown context_param field: #{field}"
64
- end
56
+ params.select{ |k, _| ctx_params.members.include? k }.each do |key, value|
57
+ ctx_params[key] = value
65
58
  end
66
59
  ctx_params[:gpu_device] = ENV['WHISPER_GPU']&.to_i || 0
67
60
 
@@ -70,22 +63,18 @@ module Whisper
70
63
  raise 'Failed to initialize Whisper model' if @ctx.null?
71
64
  end
72
65
 
73
- def default_full_params(params)
66
+ def default_full_params params = {}
74
67
  # Get default full params
75
68
  strategy = params.fetch(:sampling_strategy, Whisper::WHISPER_SAMPLING_GREEDY)
76
69
  full_params = Whisper.whisper_full_default_params(strategy)
77
70
 
78
- # Set translate to false to prevent translation to English
71
+ # Set translate to false to prevent translation to English
79
72
  full_params[:translate] = false
73
+ full_params[:language] = FFI::MemoryPointer.from_string 'auto'
80
74
 
81
75
  # Set user-provided full params
82
- user_full_params = params.fetch(:full_params, {})
83
- user_full_params.each do |key, value|
84
- if full_params.members.include?(field)
85
- full_params[key] = value
86
- else
87
- warn "Unknown full_param field: #{field}"
88
- end
76
+ params.select{ |k, _| full_params.members.include? k }.each do |key, value|
77
+ full_params[key] = value
89
78
  end
90
79
 
91
80
  full_params
@@ -1,5 +1,5 @@
1
1
  module Whisper
2
2
 
3
- VERSION = '0.3.1'
3
+ VERSION = '0.3.2'
4
4
 
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: whisper.cpp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Braulio Oliveira