|
import os |
|
import random |
|
import pandas as pd |
|
import shutil |
|
import uuid |
|
|
|
|
|
|
|
common_dir = "/data/vitsGPT/vits/" |
|
|
|
gt_wav_folder = f"{common_dir}DUMMY5/gt_test_wav/" |
|
folders = [ |
|
f"{common_dir}DUMMY5/gt_test_wav/", |
|
f"{common_dir}ori_vits/logs/emovdb_base_pretrained16/G_100000/model_test_wav/", |
|
f"{common_dir}emo_vits/logs/emovdb_emo_add_ave_pretrained16/G_100000/model_test_wav/", |
|
f"{common_dir}emo_vits/logs/emovdb_emo_add_bert_cls_pretrained16/G_100000/model_test_wav/", |
|
f"{common_dir}sem_vits/logs/emovdb_sem_mat_text_pretrained16/G_100000/model_test_wav/", |
|
f"{common_dir}sem_vits/logs/emovdb_sem_mat_phone_pretrained16/G_100000/model_test_wav/", |
|
f"{common_dir}sem_vits/logs/emovdb_sem_mat_bert_text_pretrained16/G_100000/model_test_wav/", |
|
f"{common_dir}sem_vits/logs/emovdb_sem_mat_bert_phone_pretrained16/G_100000/model_test_wav/", |
|
] |
|
|
|
num_extracted_files = 50 |
|
|
|
|
|
human_smos_dir = os.path.join(common_dir, "human_evaluation_emovdb/human_esmos_wavs") |
|
if not os.path.exists(human_smos_dir): |
|
os.makedirs(human_smos_dir) |
|
|
|
|
|
reference_files = set(os.listdir(folders[0])) |
|
consistent = all(set(os.listdir(folder)) == reference_files for folder in folders) |
|
if not consistent: |
|
raise ValueError("Folders do not have consistent file names or counts.") |
|
|
|
|
|
if not set(os.listdir(gt_wav_folder)) == reference_files: |
|
raise ValueError("gt_wav folder does not have consistent file names or counts with the reference.") |
|
|
|
|
|
sample_files = random.sample(list(reference_files), num_extracted_files) |
|
|
|
numbers = list(range(len(sample_files) * len(folders))) |
|
random.shuffle(numbers) |
|
|
|
renamed_files_paths = {} |
|
for orig in sample_files: |
|
for folder in folders: |
|
|
|
|
|
|
|
|
|
|
|
|
|
new_name = f"{numbers.pop()}.wav" |
|
|
|
src = os.path.join(folder, orig) |
|
dst = os.path.join(human_smos_dir, new_name) |
|
shutil.copy(src, dst) |
|
renamed_files_paths[src] = new_name |
|
|
|
|
|
gt_src = os.path.join(gt_wav_folder, orig) |
|
gt_dst = os.path.join(human_smos_dir, new_name.split('.')[0] + '_gt.wav') |
|
shutil.copy(gt_src, gt_dst) |
|
|
|
df_named_score = pd.DataFrame({ |
|
"original_file_path": list(renamed_files_paths.keys()), |
|
"innominated_file_path": list(renamed_files_paths.values()) |
|
}) |
|
|
|
|
|
df_innominated_score = pd.DataFrame({ |
|
"file_name": list(renamed_files_paths.values()), |
|
"Emo/Not": "", |
|
"SMOS_score": "", |
|
}) |
|
|
|
|
|
df_combined = pd.concat([df_innominated_score]) |
|
df_named_score.to_excel("emovdb_named_smos_score.xlsx", index=False) |
|
df_combined.to_excel("emovdb_innominated_smos_score.xlsx", index=False) |
|
|
|
"Files created and copied successfully." |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
df_to_sort = pd.read_excel("emovdb_innominated_smos_score.xlsx") |
|
|
|
df_to_sort['sort_key'] = df_to_sort['file_name'].str.extract('(\d+)').astype(int) |
|
|
|
df_sorted = df_to_sort.sort_values(by="sort_key") |
|
|
|
df_sorted = df_sorted.drop(columns=['sort_key']) |
|
|
|
df_sorted.to_excel("emovdb_smos_scoring.xlsx", index=False) |
|
print("File 'emovdb_smos_scoring.xlsx' created and sorted successfully.") |
|
|
|
|