diarize-ruby 0.3.12 → 0.4.0

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
  SHA1:
3
- metadata.gz: cf974c96cf25699a635fe8adceff3839eb519dfd
4
- data.tar.gz: dd4b2a3ee90d2893640110dc7b46a86086f9da56
3
+ metadata.gz: 7a8425adb99358b3c4fbaaeaf441f2f883a58f66
4
+ data.tar.gz: 7560243b10d08151264245f0c6e5a7aa4c04d158
5
5
  SHA512:
6
- metadata.gz: 9c12516dc25bd04468c4d771b29c848305807bf8a4fe3e7de2a6a64c3c45ca73aaf98cc067e2bf92890682eb5b353698c6fb1a9c1b46c677da7d83be4b119cbd
7
- data.tar.gz: 06e93c8f82a8b3ffeb9f9fc3a7b01ee06368ef91edf55747f349af80cad91839cc5385760c8024e66ea47d447956d20b4abb072f898d4e0ab9e0979ba92b9a09
6
+ metadata.gz: 63b8bb8e3540128016fe975acb85f753b4102fdea4950596e36d029a978d437e7d847ea37f8c3cde113c7044f71251a659be848b701e5c54cb001de5c9034456
7
+ data.tar.gz: f97fa7b06cba6949cbae44ca3a3d532327d72a6dadfbef5c26165e0da7d7d5b17477afeedddd8a1c95cce108b4f54793491a939f40f528b44f6c9364c42f2e2b
@@ -1,3 +1,11 @@
1
+ ## [v0.4.0] - 2016-11-15
2
+
3
+ - Add ruby GSL Math library
4
+
5
+ ## [v0.3.12] - 2016-11-14
6
+
7
+ - Alias `_as_json` and `_to_json` to be used for Drb objects
8
+
1
9
  ## [v0.3.11] - 2016-11-30
2
10
 
3
11
  - Add `Segment#as_json` and `Segment#to_json`
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
28
28
 
29
29
  spec.add_dependency "rjb", "~> 1.5"
30
30
  spec.add_dependency "to-rdf", "~> 0"
31
- spec.add_dependency "jblas-ruby", "~> 1.1"
31
+ spec.add_dependency "gsl", "~> 2"
32
32
 
33
33
  spec.add_runtime_dependency('gli', '~> 2.13.0')
34
34
  end
@@ -5,12 +5,11 @@ RJB_OPTIONS = ['-Xms16m', '-Xmx1024m']
5
5
 
6
6
  Rjb::load(RJB_LOAD_PATH, RJB_OPTIONS)
7
7
 
8
- require "matrix"
9
-
10
8
  require "uri"
11
9
  require "open-uri"
12
10
  require "digest"
13
11
  require "to_rdf"
12
+ require "gsl"
14
13
 
15
14
  require "rjb/java_object_wrapper"
16
15
 
@@ -3,7 +3,7 @@ module Diarize
3
3
  attr_reader :vector
4
4
 
5
5
  def initialize(vector)
6
- @vector = vector.is_a?(Array) ? Vector.elements(vector) : vector
6
+ @vector = vector
7
7
  end
8
8
 
9
9
  class << self
@@ -11,29 +11,28 @@ module Diarize
11
11
  def generate_from_model(model)
12
12
  # Generates a supervector from a LIUM GMM
13
13
  dim = model.nb_of_components * model.components.get(0).dim
14
- vector = Array.new(dim, 0)
14
+ vector = GSL::Vector::alloc(dim)
15
15
  model.nb_of_components.times do |k|
16
16
  gaussian = model.components.get(k)
17
17
  gaussian.dim.times do |i|
18
18
  vector[k * gaussian.dim + i] = gaussian.mean(i)
19
19
  end
20
20
  end
21
- SuperVector.new(Vector.elements(vector))
21
+ SuperVector.new(vector)
22
22
  end
23
23
 
24
24
  def ubm_gaussian_weights
25
25
  # Returns a vector of gaussian weights, same dimension as speaker's super vectors
26
26
  @@ubm_gaussian_weights ||= begin
27
27
  ubm = Speaker.ubm
28
- # weights = DoubleMatrix.new(1, ubm.supervector.dim)
29
- weights = Array.new(ubm.supervector.dim, 0)
28
+ weights = GSL::Vector::alloc(ubm.supervector.dim)
30
29
  ubm.model.nb_of_components.times do |k|
31
30
  gaussian = ubm.model.components.get(k)
32
31
  gaussian.dim.times do |i|
33
32
  weights[k * gaussian.dim + i] = gaussian.weight
34
33
  end
35
34
  end
36
- Vector.elements(weights)
35
+ weights
37
36
  end
38
37
  end
39
38
 
@@ -41,25 +40,19 @@ module Diarize
41
40
  # Returns a vector of diagonal covariances, same dimension as speaker's super vectors
42
41
  @@ubm_covariance ||= begin
43
42
  ubm = Speaker.ubm
44
- # cov = DoubleMatrix.new(1, ubm.supervector.dim)
45
- cov = Array.new(ubm.supervector.dim)
43
+ cov = GSL::Vector::alloc(ubm.supervector.dim)
46
44
  ubm.model.nb_of_components.times do |k|
47
45
  gaussian = ubm.model.components.get(k)
48
46
  gaussian.dim.times do |i|
49
47
  cov[k * gaussian.dim + i] = gaussian.getCovariance(i, i)
50
48
  end
51
49
  end
52
- Vector.elements(cov)
50
+ cov
53
51
  end
54
52
  end
55
53
 
56
54
  def divergence(sv1, sv2)
57
- # ubm_gaussian_weights.mul(((sv1.vector - sv2.vector) ** 2) / ubm_covariance).sum
58
- diff = sv1.vector - sv2.vector
59
- square = diff.map {|el| el ** 2}
60
- codiv = Vector.elements(square.each.with_index.inject([]) {|a,(el,ix)| a << el / ubm_covariance[ix]})
61
- mult = ubm_gaussian_weights.each.with_index.inject([]) {|a,(el,ix)| a << el * codiv[ix]}
62
- mult.inject(0, :+)
55
+ return ubm_gaussian_weights.mul(((sv1.vector - sv2.vector) ** 2) / ubm_covariance).sum
63
56
  end
64
57
 
65
58
  end # class
@@ -69,7 +62,7 @@ module Diarize
69
62
  end
70
63
 
71
64
  def hash
72
- @vector.hash
65
+ @vector.to_a.hash
73
66
  end
74
67
 
75
68
  def to_a
@@ -77,4 +70,4 @@ module Diarize
77
70
  end
78
71
 
79
72
  end # SuperVector
80
- end
73
+ end # Diarize
@@ -1,3 +1,3 @@
1
1
  module Diarize
2
- VERSION = "0.3.12"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -32,7 +32,8 @@ class SuperVectorTest < Test::Unit::TestCase
32
32
  def test_hash
33
33
  model = Diarize::Speaker.load_model(File.join(File.dirname(__FILE__), 'data', 'speaker1.gmm'))
34
34
  sv = Diarize::SuperVector.generate_from_model(model)
35
- assert_equal sv.vector.hash, sv.hash
35
+ assert_equal (previous_hash = sv.vector.to_a.hash), sv.hash
36
+ assert_equal previous_hash, sv.hash
36
37
  end
37
38
 
38
39
  def test_to_a
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  class VersionTest < Test::Unit::TestCase
4
4
 
5
5
  def test_current_version
6
- assert_equal "0.3.12", Diarize::VERSION
6
+ assert_equal "0.4.0", Diarize::VERSION
7
7
  end
8
8
 
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: diarize-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.12
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yves Raimond
@@ -96,19 +96,19 @@ dependencies:
96
96
  - !ruby/object:Gem::Version
97
97
  version: '0'
98
98
  - !ruby/object:Gem::Dependency
99
- name: jblas-ruby
99
+ name: gsl
100
100
  requirement: !ruby/object:Gem::Requirement
101
101
  requirements:
102
102
  - - "~>"
103
103
  - !ruby/object:Gem::Version
104
- version: '1.1'
104
+ version: '2'
105
105
  type: :runtime
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
109
  - - "~>"
110
110
  - !ruby/object:Gem::Version
111
- version: '1.1'
111
+ version: '2'
112
112
  - !ruby/object:Gem::Dependency
113
113
  name: gli
114
114
  requirement: !ruby/object:Gem::Requirement