From ddc8ac3d9aacc38b76dbb832360c4b1b83f6e269 Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Thu, 23 Dec 2021 19:52:54 -0500 Subject: [PATCH] [+] Print whether INA agree --- src/validate_cn_celeb.py | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/validate_cn_celeb.py b/src/validate_cn_celeb.py index b64c247..187de7a 100644 --- a/src/validate_cn_celeb.py +++ b/src/validate_cn_celeb.py @@ -9,6 +9,7 @@ import pygame from inaSpeechSegmenter import Segmenter from ina_main import process, get_result_percentages +from utils import color, printc def segment_all(): @@ -108,26 +109,45 @@ def manually_label_data(): """ pygame.mixer.init() + # Load existing labels + labels_json = data_dir.joinpath('id_labels.json') + id_labels = json.loads(labels_json.read_text()) if labels_json.exists() else {} + + # Load pf table + id_pfs = json.loads(data_dir.joinpath('id_pf_map.json').read_text()) + # Loop through all speaker - id_labels = {} for id_i, id in enumerate(ids): id_dir = data_dir.joinpath(id) + # Skip already identified labels + if id in id_labels: + continue + + # Get ina choice + pf = id_pfs[id] + ina_choice = 'f' if pf > 0.5 else 'm' + # Loop through all tracks until identified tracks = [f for f in os.listdir(id_dir) if f.endswith('.flac')] for track_i, audio in enumerate(tracks): # Play track sound = pygame.mixer.Sound(id_dir.joinpath(audio)) sound.play() - i = input(f'Playing speaker {id_i}/{len(ids)} - track {track_i}/{len(tracks)}\n' - f'- Identify gender. Press f / m, or anything else to play next track: ')\ + i = input(color( + f'\n&7Playing speaker {id_i}/{len(ids)} - track {track_i}/{len(tracks)}&r\n' + f'- Press f / m, or anything else to play next track: '))\ .lower().strip() sound.stop() # Labeled if i == 'f' or i == 'm': id_labels[id] = i - data_dir.joinpath('id_labels.json').write_text(json.dumps(id_labels)) + labels_json.write_text(json.dumps(id_labels)) + + # Print choice match + agree = '&aINA agrees' if ina_choice == i else '&cINA disagree' + printc(f'INA {agree} with confidence {abs(pf - 0.5) * 200:.0f}%') break