From ab9d4338cc671cb90b51a5df0654d825fbff1733 Mon Sep 17 00:00:00 2001 From: Vadim Date: Sat, 10 Jun 2023 21:25:35 +0200 Subject: [PATCH] - Fix end time smaller than start time caused by hyphen enumaration issue --- src/UltraSinger.py | 7 ++++--- src/modules/Midi/midi_creator.py | 5 ----- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/UltraSinger.py b/src/UltraSinger.py index 52d862b..38bbbfb 100644 --- a/src/UltraSinger.py +++ b/src/UltraSinger.py @@ -118,14 +118,15 @@ def add_hyphen_to_data(transcribed_data: list[TranscribedData], hyphen_words: li chunk_duration = chunk_duration / (len(hyphen_words[i])) next_start = data.start - for j, hyphens in enumerate(hyphen_words[i]): + for j in enumerate(hyphen_words[i]): + hyphenated_word_index = j[0] dup = copy.copy(data) dup.start = next_start next_start = data.end - chunk_duration * ( - len(hyphens) - 1 - j + len(hyphen_words[i]) - 1 - hyphenated_word_index ) dup.end = next_start - dup.word = hyphen_words[i][j] + dup.word = hyphen_words[i][hyphenated_word_index] dup.is_hyphen = True new_data.append(dup) diff --git a/src/modules/Midi/midi_creator.py b/src/modules/Midi/midi_creator.py index 1d09e13..33f397a 100644 --- a/src/modules/Midi/midi_creator.py +++ b/src/modules/Midi/midi_creator.py @@ -108,11 +108,6 @@ def create_midi_note_from_pitched_data(start_time: float, end_time: float, pitch start = find_nearest_index(pitched_data.times, start_time) end = find_nearest_index(pitched_data.times, end_time) - # fixme: why is end smaller as start? - if end < start: - print(f"{ULTRASINGER_HEAD} {red_highlighted('Error: end time is smaller as start time. The note is C0 now ...')}") - return "C0" - if start == end: freqs = [pitched_data.frequencies[start]] confs = [pitched_data.confidence[start]]