From b9e69703dff200101a29fae707bf0288ef7165fa Mon Sep 17 00:00:00 2001 From: yqzhishen Date: Sat, 13 Jul 2024 22:58:44 +0800 Subject: [PATCH] Add checks for negative note duration --- preprocessing/acoustic_binarizer.py | 2 +- preprocessing/variance_binarizer.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/preprocessing/acoustic_binarizer.py b/preprocessing/acoustic_binarizer.py index 052d6cce..b61c88f8 100644 --- a/preprocessing/acoustic_binarizer.py +++ b/preprocessing/acoustic_binarizer.py @@ -82,7 +82,7 @@ def load_meta_data(self, raw_data_dir: pathlib.Path, ds_id, spk_id): assert len(temp_dict['ph_seq']) == len(temp_dict['ph_dur']), \ f'Lengths of ph_seq and ph_dur mismatch in \'{item_name}\'.' assert all(ph_dur >= 0 for ph_dur in temp_dict['ph_dur']), \ - f'Negative duration found in \'{item_name}\'.' + f'Negative ph_dur found in \'{item_name}\'.' meta_data_dict[f'{ds_id}:{item_name}'] = temp_dict self.items.update(meta_data_dict) diff --git a/preprocessing/variance_binarizer.py b/preprocessing/variance_binarizer.py index a88778f8..2882cf76 100644 --- a/preprocessing/variance_binarizer.py +++ b/preprocessing/variance_binarizer.py @@ -140,7 +140,7 @@ def require(attr): assert len(temp_dict['ph_seq']) == len(temp_dict['ph_dur']), \ f'Lengths of ph_seq and ph_dur mismatch in \'{item_name}\'.' assert all(ph_dur >= 0 for ph_dur in temp_dict['ph_dur']), \ - f'Negative duration found in \'{item_name}\'.' + f'Negative ph_dur found in \'{item_name}\'.' if hparams['predict_dur']: temp_dict['ph_num'] = [int(x) for x in require('ph_num').split()] @@ -150,6 +150,8 @@ def require(attr): if hparams['predict_pitch']: temp_dict['note_seq'] = require('note_seq').split() temp_dict['note_dur'] = [float(x) for x in require('note_dur').split()] + assert all(note_dur >= 0 for note_dur in temp_dict['note_dur']), \ + f'Negative note_dur found in \'{item_name}\'.' assert len(temp_dict['note_seq']) == len(temp_dict['note_dur']), \ f'Lengths of note_seq and note_dur mismatch in \'{item_name}\'.' assert any([note != 'rest' for note in temp_dict['note_seq']]), \