From e12f0de936f6e0102e3e9ccbd5a394fec7804d01 Mon Sep 17 00:00:00 2001 From: Vadim Date: Mon, 22 May 2023 22:11:05 +0200 Subject: [PATCH 1/7] - Added LineBonus calculation --- .../Ultrastar/ultrastar_score_calculator.py | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/moduls/Ultrastar/ultrastar_score_calculator.py b/moduls/Ultrastar/ultrastar_score_calculator.py index 9d3c567..ce2f99e 100644 --- a/moduls/Ultrastar/ultrastar_score_calculator.py +++ b/moduls/Ultrastar/ultrastar_score_calculator.py @@ -1,7 +1,8 @@ from moduls.Midi.midi_creator import create_midi_note_from_pitched_data from moduls.Ultrastar.ultrastar_converter import get_start_time_from_ultrastar, get_end_time_from_ultrastar, \ ultrastar_note_to_midi_note -from moduls.Log import PRINT_ULTRASTAR, print_blue_highlighted_text, print_gold_highlighted_text, print_light_blue_highlighted_text, print_underlined_text, print_cyan_highlighted_text +from moduls.Log import PRINT_ULTRASTAR, print_blue_highlighted_text, print_gold_highlighted_text, \ + print_light_blue_highlighted_text, print_underlined_text, print_cyan_highlighted_text import librosa # Todo: LineBonus @@ -36,11 +37,13 @@ def add_point(noteType, points): def print_score(points): + # todo: here also a score calculation !?! notes = MAX_SONG_SCORE * (points.notes + points.rap) / points.parts - line_bonus = 0 golden = points.golden_notes + points.golden_rap - score = notes + line_bonus + golden - print(PRINT_ULTRASTAR + " Total: {}, notes: {}, line bonus: {}, golden notes: {}".format(print_cyan_highlighted_text(str(round(score))), print_blue_highlighted_text(str(round(notes))), print_light_blue_highlighted_text(str(round(line_bonus))), print_gold_highlighted_text(str(round(golden))))) + score = notes + points.line_bonus + golden + print(PRINT_ULTRASTAR + " Total: {}, notes: {}, line bonus: {}, golden notes: {}".format( + print_cyan_highlighted_text(str(round(score))), print_blue_highlighted_text(str(round(notes))), + print_light_blue_highlighted_text(str(round(points.line_bonus))), print_gold_highlighted_text(str(round(golden))))) def print_score_calculation(pitched_data, ultrastar_class): @@ -49,6 +52,8 @@ def print_score_calculation(pitched_data, ultrastar_class): simple_points = Points() accurate_points = Points() + line_bonus_per_line = MAX_SONG_LINE_BONUS / len(ultrastar_class.words) + for i in range(len(ultrastar_class.words)): if ultrastar_class.words == "": continue @@ -59,8 +64,11 @@ def print_score_calculation(pitched_data, ultrastar_class): start_time = get_start_time_from_ultrastar(ultrastar_class, i) end_time = get_end_time_from_ultrastar(ultrastar_class, i) duration = end_time - start_time - parts_len = 0.01 + parts_len = 0.01 # todo: should be beat length parts = duration / parts_len + reachable_line_bonus_per_line = line_bonus_per_line / parts_len + accurate_part_line_bonus_points = 0 + simple_part_line_bonus_points = 0 ultrastar_midi_note = ultrastar_note_to_midi_note(int(ultrastar_class.pitches[i])) ultrastar_note = librosa.midi_to_note(ultrastar_midi_note) @@ -72,14 +80,20 @@ def print_score_calculation(pitched_data, ultrastar_class): if pitch_note[:-1] == ultrastar_note[:-1]: accurate_points = add_point(ultrastar_class.noteType[i], accurate_points) + accurate_part_line_bonus_points += 1 if pitch_note == ultrastar_note: simple_points = add_point(ultrastar_class.noteType[i], simple_points) + simple_part_line_bonus_points += 1 accurate_points.parts += 1 simple_points.parts += 1 - # todo: line_bonus + if accurate_part_line_bonus_points >= reachable_line_bonus_per_line: + accurate_points.line_bonus += line_bonus_per_line + + if simple_part_line_bonus_points >= reachable_line_bonus_per_line: + simple_points.line_bonus += line_bonus_per_line print("{} {} points".format(PRINT_ULTRASTAR, print_underlined_text("Simple"))) print_score(simple_points) From a5927c126e6586cc5fe22c07e85eb8e82a05785a Mon Sep 17 00:00:00 2001 From: Vadim Date: Tue, 23 May 2023 00:23:09 +0200 Subject: [PATCH 2/7] - No linebreak before file end ' E' --- moduls/Ultrastar/ultrastar_writer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moduls/Ultrastar/ultrastar_writer.py b/moduls/Ultrastar/ultrastar_writer.py index e0e2dd8..11c97c3 100644 --- a/moduls/Ultrastar/ultrastar_writer.py +++ b/moduls/Ultrastar/ultrastar_writer.py @@ -66,7 +66,7 @@ def create_ultrastar_txt_from_automation(transcribed_data, note_numbers, ultrast else: silence = 0 - if silence > 0.3: + if silence > 0.3 and i != len(transcribed_data) - 1: # - 10 # '-' end of current sing part # 'n1' show next at time in real beat From c78be250aaed7f435c10d10cced6afe9093073b2 Mon Sep 17 00:00:00 2001 From: Vadim Rangnau <36919102+rakuri255@users.noreply.github.com> Date: Tue, 23 May 2023 12:33:55 +0200 Subject: [PATCH 3/7] Update README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0c765e0..c3d37e2 100644 --- a/README.md +++ b/README.md @@ -52,8 +52,8 @@ _Not all options working now!_ (-m Create midi file) # In Progress [transcription] - # Default is whisper tiny - --whisper tiny|base|small|medium|large + # Default is whisper + --whisper tiny|base|small|medium|large >> ((default) is large) --vosk Needs model [extra] @@ -63,8 +63,8 @@ _Not all options working now!_ --create_audio_chunks True|False >> ((default) is False) [pitcher] - # Default is crepe full - --crepe tiny|small|medium|large|full + # Default is crepe + --crepe tiny|small|medium|large|full >> ((default) is full) ``` For standard use, you only need to use [opt]. All other options are optional. From 59ca9c8a66aecd0bc986cb76cbb0bcbe1f693faf Mon Sep 17 00:00:00 2001 From: Vadim Rangnau <36919102+rakuri255@users.noreply.github.com> Date: Tue, 23 May 2023 15:06:02 +0200 Subject: [PATCH 4/7] Update pitcher.py Corrected pitcher state log --- moduls/Pitcher/pitcher.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moduls/Pitcher/pitcher.py b/moduls/Pitcher/pitcher.py index 20aee35..f7b701a 100644 --- a/moduls/Pitcher/pitcher.py +++ b/moduls/Pitcher/pitcher.py @@ -7,7 +7,7 @@ from moduls.Log import print_blue_highlighted_text, print_red_highlighted_text def get_pitch_with_crepe_file(filename, step_size, model_capacity): - print("{} Transcribing with {} and model {} and {} as worker".format(PRINT_ULTRASTAR, + print("{} Pitching with {} and model {} and {} as worker".format(PRINT_ULTRASTAR, print_blue_highlighted_text("crepe"), print_blue_highlighted_text(model_capacity), print_red_highlighted_text("cpu"))) From 9d36e6917c7fa4cdb3823de0c0aca7925125c144 Mon Sep 17 00:00:00 2001 From: Vadim Date: Tue, 23 May 2023 17:35:48 +0200 Subject: [PATCH 5/7] - fix line bonus calculation --- .../Ultrastar/ultrastar_score_calculator.py | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/moduls/Ultrastar/ultrastar_score_calculator.py b/moduls/Ultrastar/ultrastar_score_calculator.py index ce2f99e..5e493db 100644 --- a/moduls/Ultrastar/ultrastar_score_calculator.py +++ b/moduls/Ultrastar/ultrastar_score_calculator.py @@ -38,7 +38,8 @@ def add_point(noteType, points): def print_score(points): # todo: here also a score calculation !?! - notes = MAX_SONG_SCORE * (points.notes + points.rap) / points.parts + max_score = MAX_SONG_SCORE if points.line_bonus == 0 else MAX_SONG_SCORE - MAX_SONG_LINE_BONUS + notes = max_score * (points.notes + points.rap) / points.parts golden = points.golden_notes + points.golden_rap score = notes + points.line_bonus + golden print(PRINT_ULTRASTAR + " Total: {}, notes: {}, line bonus: {}, golden notes: {}".format( @@ -64,18 +65,19 @@ def print_score_calculation(pitched_data, ultrastar_class): start_time = get_start_time_from_ultrastar(ultrastar_class, i) end_time = get_end_time_from_ultrastar(ultrastar_class, i) duration = end_time - start_time - parts_len = 0.01 # todo: should be beat length - parts = duration / parts_len - reachable_line_bonus_per_line = line_bonus_per_line / parts_len + step_size = 0.01 # todo: should be beat length ? + parts = int(duration / step_size) + + reachable_line_bonus_per_line = line_bonus_per_line / parts accurate_part_line_bonus_points = 0 simple_part_line_bonus_points = 0 ultrastar_midi_note = ultrastar_note_to_midi_note(int(ultrastar_class.pitches[i])) ultrastar_note = librosa.midi_to_note(ultrastar_midi_note) - for p in range(int(parts)): - st = start_time + parts_len * p - end = st + parts_len + for p in range(parts): + st = start_time + step_size * p + end = st + step_size pitch_note = create_midi_note_from_pitched_data(st, end, pitched_data) if pitch_note[:-1] == ultrastar_note[:-1]: @@ -89,11 +91,11 @@ def print_score_calculation(pitched_data, ultrastar_class): accurate_points.parts += 1 simple_points.parts += 1 - if accurate_part_line_bonus_points >= reachable_line_bonus_per_line: - accurate_points.line_bonus += line_bonus_per_line + if accurate_part_line_bonus_points >= parts: + accurate_points.line_bonus += reachable_line_bonus_per_line - if simple_part_line_bonus_points >= reachable_line_bonus_per_line: - simple_points.line_bonus += line_bonus_per_line + if simple_part_line_bonus_points >= parts: + simple_points.line_bonus += reachable_line_bonus_per_line print("{} {} points".format(PRINT_ULTRASTAR, print_underlined_text("Simple"))) print_score(simple_points) From 8f34ff474be36e734b3e6340810ba443e1442d87 Mon Sep 17 00:00:00 2001 From: Vadim Date: Tue, 23 May 2023 21:17:23 +0200 Subject: [PATCH 6/7] - Added description "how to use the source" --- README.md | 39 +++++++++++++++++++++++++++------------ requirements.txt | 2 +- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index c3d37e2..662a461 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,33 @@ This will help me alot to keep this project alive and improve it. Buy Me A Coffee Become a Patron -## How to use +## How to use this source code + +### With Console (Windows) + +* Install Python 3.10 (older and newer versions has some breaking changes). [Download](https://www.python.org/downloads/) +* Also install ffmpeg separately with PATH. [Download](https://www.ffmpeg.org/download.html) +* Open a console (CMD) and navigate to the project folder. +* Type `py -m venv .venv` and press enter. If this does not work, try instead of `py` `python` or `python3`. + * This will always take the newest Python version. If you have multiple versions installed, you can use `py -0p` to see all installed versions. + * Build with correct version use `py -3.10 -m venv .venv`. +* Wait until the console is done with creating the environment. This can take a while. +* Type `.venv\Scripts\activate` and press enter. +* You should see now a `(.venv)` in front of your console line. +* Install the requirements with `pip install -r requirements.txt`. +* Now you can use the UltraSinger source code with `py UltraSinger.py [opt] [mode] [transcription] [pitcher] [extra]`. See [How to use](#how-to-use) for more information. + +For more information about Python environments look [here](https://code.visualstudio.com/docs/python/environments#_global-virtual-or-conda-environments). + +As copy: + +```commandline +py -m venv .venv +.venv\Scripts\activate +pip install -r requirements.txt +``` + +## How to use the App _Not all options working now!_ ```commandline @@ -159,14 +185,3 @@ for low male voices. Accurate is the real tone specified in the txt. I had txt f singable by humans, but you could still reach the 10k points in the game. The accuracy is important here, because from this MIDI and sheet are created. And you also want to have accurate files -## How to use this source code - -Install Python 3.10 (older and newer versions has some breaking changes). -You should install and use `venv` or `conda`. -For VSCode look [here](https://code.visualstudio.com/docs/python/environments#_global-virtual-or-conda-environments). - -After that you need to install the requirements from `requirements.txt`. - -Also install ffmpeg separately. - -Then just use the `How to use` commands, described above. diff --git a/requirements.txt b/requirements.txt index 1a02274..db1f347 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,7 @@ pydub==0.25.1 Levenshtein==0.20.9 scipy==1.10.0 vosk==0.3.45 -tensorflow~=2.11.0 +tensorflow~=2.12.0 matplotlib~=3.7.1 yt_dlp~=2023.3.4 numpy~=1.23.5 From 0ec481f66a5b7722886e334a72561b6341564c5e Mon Sep 17 00:00:00 2001 From: Vadim Date: Thu, 25 May 2023 21:06:10 +0200 Subject: [PATCH 7/7] - Fix line bonus calculation and fix simple/accurate missmatch --- .../Ultrastar/ultrastar_score_calculator.py | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/moduls/Ultrastar/ultrastar_score_calculator.py b/moduls/Ultrastar/ultrastar_score_calculator.py index 5e493db..10c272d 100644 --- a/moduls/Ultrastar/ultrastar_score_calculator.py +++ b/moduls/Ultrastar/ultrastar_score_calculator.py @@ -5,12 +5,6 @@ from moduls.Log import PRINT_ULTRASTAR, print_blue_highlighted_text, print_gold_ print_light_blue_highlighted_text, print_underlined_text, print_cyan_highlighted_text import librosa -# Todo: LineBonus -# if (Ini.LineBonus > 0) then -# MaxSongPoints := MAX_SONG_SCORE - MAX_SONG_LINE_BONUS -# else -# MaxSongPoints := MAX_SONG_SCORE; - MAX_SONG_SCORE = 10000 MAX_SONG_LINE_BONUS = 1000 @@ -53,7 +47,7 @@ def print_score_calculation(pitched_data, ultrastar_class): simple_points = Points() accurate_points = Points() - line_bonus_per_line = MAX_SONG_LINE_BONUS / len(ultrastar_class.words) + reachable_line_bonus_per_word = MAX_SONG_LINE_BONUS / len(ultrastar_class.words) for i in range(len(ultrastar_class.words)): if ultrastar_class.words == "": @@ -67,8 +61,8 @@ def print_score_calculation(pitched_data, ultrastar_class): duration = end_time - start_time step_size = 0.01 # todo: should be beat length ? parts = int(duration / step_size) + parts = 1 if parts == 0 else parts - reachable_line_bonus_per_line = line_bonus_per_line / parts accurate_part_line_bonus_points = 0 simple_part_line_bonus_points = 0 @@ -81,24 +75,26 @@ def print_score_calculation(pitched_data, ultrastar_class): pitch_note = create_midi_note_from_pitched_data(st, end, pitched_data) if pitch_note[:-1] == ultrastar_note[:-1]: - accurate_points = add_point(ultrastar_class.noteType[i], accurate_points) - accurate_part_line_bonus_points += 1 - - if pitch_note == ultrastar_note: + # Ignore octave high simple_points = add_point(ultrastar_class.noteType[i], simple_points) simple_part_line_bonus_points += 1 + if pitch_note == ultrastar_note: + # Octave high must be the same + accurate_points = add_point(ultrastar_class.noteType[i], accurate_points) + accurate_part_line_bonus_points += 1 + accurate_points.parts += 1 simple_points.parts += 1 if accurate_part_line_bonus_points >= parts: - accurate_points.line_bonus += reachable_line_bonus_per_line + accurate_points.line_bonus += reachable_line_bonus_per_word if simple_part_line_bonus_points >= parts: - simple_points.line_bonus += reachable_line_bonus_per_line + simple_points.line_bonus += reachable_line_bonus_per_word - print("{} {} points".format(PRINT_ULTRASTAR, print_underlined_text("Simple"))) + print("{} {} points".format(PRINT_ULTRASTAR, print_underlined_text("Simple (octave high ignored)"))) print_score(simple_points) - print("{} {} points:".format(PRINT_ULTRASTAR, print_underlined_text("Accurate"))) + print("{} {} points:".format(PRINT_ULTRASTAR, print_underlined_text("Accurate (octave high matches)"))) print_score(accurate_points)