whisper.cpp 0.3.0 → 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: 7d83008a506279672a2d585d35f232940c6d81ee6175ea866baa9965684fa4a8
4
- data.tar.gz: 6e79798baa580cbcd6cdfb886f197bb6a7c1533a1b9ad9d6fa1d1b15cd708028
3
+ metadata.gz: 3d1b91cc9ac6e7682429f261d3e9b283c4c34ef246a2e88d07f1c294d145d1f4
4
+ data.tar.gz: be2a0ff1c4eda542685c209e6c64b7f3f3f902c4353534747922ea89c42ef24d
5
5
  SHA512:
6
- metadata.gz: f41063a2b14007e68f7084c5c1e19e513d7ff89648cb6cb2fe3dfdd8982c868d20b45639799b3d57d210a7cd6aabaf7d5cc23d2a03b821f5dffa2a827dadf4a8
7
- data.tar.gz: 5c69521555fde8f6080a437a927af31741978fc66efca0e825f4be058739ebd988e7df218b7cd485773ff99466c57361e256e684a912042e959191764845f342
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,19 +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
 
71
+ # Set translate to false to prevent translation to English
72
+ full_params[:translate] = false
73
+ full_params[:language] = FFI::MemoryPointer.from_string 'auto'
74
+
78
75
  # Set user-provided full params
79
- user_full_params = params.fetch(:full_params, {})
80
- user_full_params.each do |key, value|
81
- if full_params.members.include?(field)
82
- full_params[key] = value
83
- else
84
- warn "Unknown full_param field: #{field}"
85
- end
76
+ params.select{ |k, _| full_params.members.include? k }.each do |key, value|
77
+ full_params[key] = value
86
78
  end
87
79
 
88
80
  full_params
@@ -1,5 +1,5 @@
1
1
  module Whisper
2
2
 
3
- VERSION = '0.3.0'
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.0
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Braulio Oliveira