Skip to content

Commit

Permalink
fix logic error
Browse files Browse the repository at this point in the history
  • Loading branch information
robin1001 committed Nov 5, 2023
1 parent f00f358 commit 8ceb1d1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion wespeaker/cli/speaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ def extract_embedding(self, audio_path: str, apply_vad: bool = False):
def compute_similarity(self, audio_path1: str, audio_path2) -> float:
e1 = self.extract_embedding(audio_path1, True)
e2 = self.extract_embedding(audio_path2, True)
return self.cosine_distance(e1, e2)
if e1 is None or e2 is None:
return 0.0
else:
return self.cosine_distance(e1, e2)

def cosine_distance(self, e1, e2):
return np.dot(e1, e2) / (norm(e1) * norm(e2))
Expand Down

0 comments on commit 8ceb1d1

Please sign in to comment.