Skip to content

Commit e2090ea

Browse files
authored
[runtime] cosine score normalization (wenet-e2e#408)
* [runtime] cosine score normalization * [runtime] cosine score normalization
1 parent 5a8ae4c commit e2090ea

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

runtime/core/speaker/speaker_engine.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ float SpeakerEngine::CosineSimilarity(const std::vector<float>& emb1,
168168
std::inner_product(emb2.begin(), emb2.end(), emb2.begin(), 0.0);
169169
dot /= std::max(std::sqrt(emb1_sum) * std::sqrt(emb2_sum),
170170
std::numeric_limits<float>::epsilon());
171+
dot = (dot + 1.0) / 2.0; // normalize: [-1, 1] => [0, 1]
171172
return dot;
172173
}
173174

0 commit comments

Comments
 (0)