[O] Fix validation

This commit is contained in:
Hykilpikonna
2021-12-24 15:03:05 -05:00
parent ddc8ac3d9a
commit 3eaa8228f2
+14 -7
View File
@@ -117,7 +117,7 @@ def manually_label_data():
id_pfs = json.loads(data_dir.joinpath('id_pf_map.json').read_text()) id_pfs = json.loads(data_dir.joinpath('id_pf_map.json').read_text())
# Loop through all speaker # Loop through all speaker
for id_i, id in enumerate(ids): for id in sorted(ids):
id_dir = data_dir.joinpath(id) id_dir = data_dir.joinpath(id)
# Skip already identified labels # Skip already identified labels
@@ -125,7 +125,7 @@ def manually_label_data():
continue continue
# Get ina choice # Get ina choice
pf = id_pfs[id] pf = id_pfs.get(id, -1)
ina_choice = 'f' if pf > 0.5 else 'm' ina_choice = 'f' if pf > 0.5 else 'm'
# Loop through all tracks until identified # Loop through all tracks until identified
@@ -135,26 +135,33 @@ def manually_label_data():
sound = pygame.mixer.Sound(id_dir.joinpath(audio)) sound = pygame.mixer.Sound(id_dir.joinpath(audio))
sound.play() sound.play()
i = input(color( i = input(color(
f'\n&7Playing speaker {id_i}/{len(ids)} - track {track_i}/{len(tracks)}&r\n' f'\n&7Playing speaker {id[-3:]}/{len(ids)} - track {track_i}/{len(tracks)} - {audio}&r'
f'- Press f / m, or anything else to play next track: '))\ f'\n- Press f / m, or anything else to play next track: '))\
.lower().strip() .lower().strip()
sound.stop() sound.stop()
# Skip
if i == 's':
break
# Labeled # Labeled
if i == 'f' or i == 'm': if i == 'f' or i == 'm':
id_labels[id] = i id_labels[id] = i
labels_json.write_text(json.dumps(id_labels)) labels_json.write_text(json.dumps(id_labels))
# Print choice match # Print choice match
agree = '&aINA agrees' if ina_choice == i else '&cINA disagree' if pf != -1:
printc(f'INA {agree} with confidence {abs(pf - 0.5) * 200:.0f}%') agree = '&aINA agrees' if ina_choice == i else '&cINA disagree'
printc(f'{agree} with confidence {abs(pf - 0.5) * 200:.0f}%')
else:
printc(f"&7INA didn't identify any voice")
break break
if __name__ == '__main__': if __name__ == '__main__':
cn_celeb_root = Path('C:/Users/me/Workspace/Data/CN-Celeb_flac') cn_celeb_root = Path('C:/Users/me/Workspace/Data/CN-Celeb_flac')
data_dir = cn_celeb_root.joinpath('data') data_dir = cn_celeb_root.joinpath('data')
ids = [id for id in os.listdir(data_dir) if id.startswith('id')] ids = [id for id in os.listdir(data_dir) if id.startswith('id0')]
# segment_all() # segment_all()
# graph_histogram() # graph_histogram()