Skip to content

Commit

Permalink
specify comments and remove redundant code
Browse files Browse the repository at this point in the history
  • Loading branch information
Merakist committed Dec 29, 2023
1 parent 15ae82f commit 9ebc902
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
3 changes: 0 additions & 3 deletions egs/metrics/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ while true; do
esac
done

######## Set CUDA_VISIBLE_DEVICES ###########
export CUDA_VISIBLE_DEVICES=$gpu

######## Calculate Objective Metrics ###########
CUDA_VISIBLE_DEVICES=$gpu python "$work_dir"/bins/calc_metrics.py \
--ref_dir $ref_dir \
Expand Down
21 changes: 18 additions & 3 deletions evaluation/metrics/similarity/resemblyzer_similarity.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@


def load_wavs(directory):
"""Load all WAV files from the given directory."""
"""Load all WAV files from the given directory.
Args:
directory (str): Path to the directory containing WAV files.
"""

wavs = []
wav_names = []
Expand All @@ -26,7 +30,12 @@ def load_wavs(directory):


def calculate_cosine_similarity(embeddings1, embeddings2, names1, names2):
"""Calculate cosine similarity between two sets of embeddings."""
"""Calculate cosine similarity between two sets of embeddings.
Args:
embeddings1 & 2 (list): List of embeddings.
names1 & 2 (list): List of filenames.
"""

similarity_info = []
for i, emb1 in enumerate(embeddings1):
Expand All @@ -39,7 +48,13 @@ def calculate_cosine_similarity(embeddings1, embeddings2, names1, names2):


def extract_resemblyzer_similarity(target_path, reference_path, dump_dir):
"""Extract similarity between utterances using resemblyzer."""
"""Extract similarity between utterances using resemblyzer.
Args:
target_path (str): Path to the directory containing target utterances.
reference_path (str): Path to the directory containing reference utterances.
dump_dir (str): Path to the directory where similarity results are dumped.
"""

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

Expand Down

0 comments on commit 9ebc902

Please sign in to comment.