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 +4 -4
- data/CHANGELOG.md +8 -0
- data/diarize-ruby.gemspec +1 -1
- data/lib/diarize.rb +1 -2
- data/lib/diarize/super_vector.rb +10 -17
- data/lib/diarize/version.rb +1 -1
- data/test/super_vector_test.rb +2 -1
- data/test/version_test.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a8425adb99358b3c4fbaaeaf441f2f883a58f66
|
4
|
+
data.tar.gz: 7560243b10d08151264245f0c6e5a7aa4c04d158
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63b8bb8e3540128016fe975acb85f753b4102fdea4950596e36d029a978d437e7d847ea37f8c3cde113c7044f71251a659be848b701e5c54cb001de5c9034456
|
7
|
+
data.tar.gz: f97fa7b06cba6949cbae44ca3a3d532327d72a6dadfbef5c26165e0da7d7d5b17477afeedddd8a1c95cce108b4f54793491a939f40f528b44f6c9364c42f2e2b
|
data/CHANGELOG.md
CHANGED
data/diarize-ruby.gemspec
CHANGED
data/lib/diarize.rb
CHANGED
data/lib/diarize/super_vector.rb
CHANGED
@@ -3,7 +3,7 @@ module Diarize
|
|
3
3
|
attr_reader :vector
|
4
4
|
|
5
5
|
def initialize(vector)
|
6
|
-
@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 =
|
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(
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
50
|
+
cov
|
53
51
|
end
|
54
52
|
end
|
55
53
|
|
56
54
|
def divergence(sv1, sv2)
|
57
|
-
|
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
|
data/lib/diarize/version.rb
CHANGED
data/test/super_vector_test.rb
CHANGED
@@ -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
|
data/test/version_test.rb
CHANGED
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.
|
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:
|
99
|
+
name: gsl
|
100
100
|
requirement: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
102
|
- - "~>"
|
103
103
|
- !ruby/object:Gem::Version
|
104
|
-
version: '
|
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: '
|
111
|
+
version: '2'
|
112
112
|
- !ruby/object:Gem::Dependency
|
113
113
|
name: gli
|
114
114
|
requirement: !ruby/object:Gem::Requirement
|