diff --git a/.gitignore b/.gitignore index acdad70..58d39a7 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,6 @@ test_input test_output # default output folder -output \ No newline at end of file +output +/UltraSinger*.spec +/registry_path.txt diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 4e0e773..e970413 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -1,3 +1,8 @@ +# Version: 0.0.11 +Date: 2024.06.02 +- Changes: + - Better linebreak calculation + # Version: 0.0.10 Date: 2024.05.01 - Fix: diff --git a/pytest/modules/UltraStar/test_ultrastar_writer.py b/pytest/modules/UltraStar/test_ultrastar_writer.py index a51596f..514da00 100644 --- a/pytest/modules/UltraStar/test_ultrastar_writer.py +++ b/pytest/modules/UltraStar/test_ultrastar_writer.py @@ -3,7 +3,7 @@ import unittest from packaging import version from unittest.mock import patch, mock_open -from src.modules.Ultrastar.ultrastar_writer import create_ultrastar_txt_from_automation +from src.modules.Ultrastar.ultrastar_writer import create_ultrastar_txt_from_automation, deviation from src.modules.Speech_Recognition.TranscribedData import TranscribedData from src.modules.Ultrastar.ultrastar_txt import UltrastarTxtValue, UltrastarTxtTag @@ -121,9 +121,7 @@ class TestCreateUltrastarTxt(unittest.TestCase): expected_calls.append(f"#{UltrastarTxtTag.CREATOR}:{default_ultrastar_class.creator}\n") expected_calls.append(f"#{UltrastarTxtTag.COMMENT}:{default_ultrastar_class.comment}\n") expected_calls.append(": 0 52 1 UltraSinger \n") - expected_calls.append("- 52\n") expected_calls.append(": 65 39 2 is \n") - expected_calls.append("- 104\n") expected_calls.append(": 130 52 3 cool! \n") expected_calls.append("E") @@ -152,9 +150,7 @@ class TestCreateUltrastarTxt(unittest.TestCase): expected_calls.append(f"#{UltrastarTxtTag.CREATOR}:{default_ultrastar_class.creator}\n") expected_calls.append(f"#{UltrastarTxtTag.COMMENT}:{default_ultrastar_class.comment}\n") expected_calls.append(": 0 52 1 UltraSinger \n") - expected_calls.append("- 52\n") expected_calls.append(": 65 39 2 is \n") - expected_calls.append("- 104\n") expected_calls.append(": 130 52 3 cool! \n") expected_calls.append("E") @@ -169,5 +165,50 @@ class TestCreateUltrastarTxt(unittest.TestCase): ) return mock_file + def test_most_common_silent_part_CorTaySnf(self): + # Arrange + val = [0.020000000000000018, 0.0, 0.020000000000000018, 0.019999999999999796, 0.039999999999999813, 0.46099999999999985, 0.040000000000000036, 0.03999999999999959, 0.040000000000000036, 0.040000000000000036, 0.040000000000000036, 5.702, 0.02000000000000135, 0.21999999999999886, 0.03999999999999915, 0.040000000000000924, 0.019999999999999574, 0.14000000000000057, 0.5999999999999996, 0.0600000000000005, 0.0, 0.0, 0.019999999999999574, 0.0, 0.02000000000000135, 0.03999999999999915, 0.27999999999999936, 0.03999999999999915, 0.02000000000000135, 0.05999999999999872, 0.03999999999999915, 0.03999999999999915, 0.0600000000000005, 0.02000000000000135, 0.040000000000000924, 0.019999999999999574, 0.040000000000000924, 10.298999999999998, 10.557999999999996, 0.01999999999999602, 0.3810000000000002, 0.03999999999999915, 0.10000000000000142, 0.020000000000003126, 0.05999999999999517, 0.03999999999999915, 3.347999999999999, 0.12000000000000455, 0.14000000000000057, 0.020000000000003126, 0.0, 0.0, 0.7199999999999989, 0.060000000000002274, 0.0799999999999983, 0.060000000000002274, 0.12000000000000455, 1.3530000000000015, 0.30000000000000426, 0.05999999999999517, 0.0799999999999983, 0.10000000000000142, 0.0799999999999983, 0.09999999999999432, 0.0799999999999983, 0.10000000000000142, 3.201999999999998, 0.0799999999999983, 0.0799999999999983, 0.2610000000000028, 0.09999999999999432, 0.0, 0.0, 0.45999999999999375, 0.03999999999999915, 0.060000000000002274, 0.0, 0.0800000000000054, 13.022999999999996, 0.1599999999999966, 0.04000000000000625, 0.05999999999998806, 0.01999999999999602, 0.0799999999999983, 0.04000000000000625, 0.060000000000002274, 0.020000000000010232, 1.1110000000000042, 0.060000000000002274, 0.01999999999999602, 0.0, 0.28000000000000114, 0.05999999999998806, 1.3870000000000005, 0.060000000000002274, 0.0799999999999983, 0.03999999999999204, 0.01999999999999602, 0.060000000000002274, 0.01999999999999602, 0.060000000000002274, 0.01999999999999602, 1.5009999999999906, 0.01999999999999602, 0.0, 0.060000000000002274, 0.0799999999999983, 0.12000000000000455, 0.060000000000002274, 1.3410000000000082, 0.0, 0.060000000000002274, 0.0800000000000125, 0.060000000000002274, 0.14000000000000057, 1.4209999999999923, 0.1799999999999926, 0.1600000000000108, 0.060000000000002274, 0.060000000000002274, 0.0, 0.04000000000000625, 1.4609999999999985, 0.01999999999999602, 0.020000000000010232, 0.0, 0.03999999999999204, 0.0799999999999983, 0.060000000000002274, 3.307000000000002, 0.03999999999999204, 0.01999999999999602, 0.01999999999999602, 0.09999999999999432, 0.04000000000000625, 0.01999999999999602, 0.04000000000000625, 0.060000000000002274, 0.04000000000000625, 0.020000000000010232, 0.03999999999999204, 0.1600000000000108, 0.060000000000002274, 0.12000000000000455, 0.01999999999999602, 13.403999999999996, 0.10000000000000853, 0.10000000000000853, 0.11999999999999034, 0.0, 0.0799999999999983, 0.09999999999999432, 0.060000000000002274, 3.4599999999999937, 0.0, 0.10000000000002274, 0.18000000000000682, 0.11999999999997613, 2.552000000000021, 0.0800000000000125, 1.4210000000000207, 0.07999999999998408, 0.13999999999998636, 0.22100000000000364, 0.12000000000000455, 0.060000000000002274, 0.09999999999999432, 0.14000000000001478, 3.7220000000000084, 0.01999999999998181, 0.09999999999999432, 0.09999999999999432, 0.18000000000000682, 0.12000000000000455, 0.9000000000000057, 0.060000000000002274, 0.060000000000002274, 0.0, 0.03999999999999204, 0.03999999999999204, 0.37999999999999545, 0.060000000000002274, 0.03999999999999204, 0.03999999999999204, 0.12000000000000455, 0.03999999999999204, 0.060000000000002274, 0.12000000000000455, 0.020000000000010232, 1.4609999999999843, 0.0800000000000125, 0.020000000000010232, 0.07999999999998408, 0.03999999999999204, 0.21999999999999886, 1.281000000000006, 0.060000000000002274, 0.060000000000002274, 0.060000000000002274, 0.03999999999999204, 0.03999999999999204, 1.2800000000000011, 0.01999999999998181, 0.060000000000002274, 0.0, 0.040000000000020464, 0.060000000000002274, 0.1599999999999966, 2.009999999999991, 0.09999999999999432, 0.020000000000010232, 0.040000000000020464, 0.03999999999999204, 0.0, 0.060000000000002274, 0.12000000000000455, 1.3410000000000082, 0.07999999999998408, 0.020000000000010232, 0.12000000000000455, 0.01999999999998181, 0.14000000000001478, 0.03999999999999204, 0.30000000000001137, 1.4209999999999923, 0.05999999999997385, 0.07999999999998408, 0.03999999999999204, 0.07999999999998408, 0.0800000000000125, 0.12000000000000455, 2.3220000000000027, 0.2599999999999909, 0.03999999999999204, 0.0800000000000125, 0.0, 0.03999999999999204, 0.060000000000002274, 0.060000000000002274, 0.03999999999999204, 0.03999999999999204, 0.040000000000020464, 0.12000000000000455, 0.06100000000000705, 0.020000000000010232, 0.03999999999999204, 0.03999999999999204, 26.329000000000008, 0.05999999999997385, 0.040000000000020464, 0.0, 0.09999999999999432, 0.07999999999998408, 0.09999999999999432, 1.3810000000000002, 0.040000000000020464, 0.03999999999999204, 0.03999999999999204, 0.09999999999999432, 0.0800000000000125, 0.12000000000000455, 1.3810000000000002, 0.07999999999998408, 0.12000000000000455, 0.12000000000000455, 0.0800000000000125, 1.9370000000000118, 0.0800000000000125, 0.03999999999999204, 0.14000000000001478, 0.020000000000010232, 0.03999999999999204, 0.060000000000002274, 0.0, 0.020000000000010232, 0.48699999999999477, 0.060000000000002274, 0.01999999999998181, 0.09999999999999432, 0.040000000000020464, 0.03999999999999204, 0.12000000000000455, 0.9199999999999875, 0.08099999999998886, 0.060000000000002274, 0.07999999999998408, 0.09999999999999432, 0.060000000000002274, 0.09999999999999432, 1.4809999999999945, 0.0, 0.1599999999999966, 0.020000000000010232, 0.03999999999999204, 0.07999999999998408, 0.0, 2.7450000000000045, 0.03999999999999204, 0.03999999999999204, 0.09999999999999432, 0.0, 0.060000000000002274, 0.020000000000010232, 0.020000000000010232, 0.060000000000002274, 0.03999999999999204, 0.01999999999998181, 0.03999999999999204, 0.13999999999998636, 0.03999999999999204, 0.03999999999999204, 0.03999999999999204, 0.01999999999998181, 2.4029999999999916, 0.020000000000010232, 0.020000000000010232, 0.03999999999999204, 0.14000000000001478, 0.040000000000020464, 0.04099999999999682, 0.040000000000020464, 0.040000000000020464] + + # Act + result = deviation(val) + + # Assert + self.assertLessEqual(result, 0.45) + self.assertGreaterEqual(result, 0.37) + + def test_most_common_silent_part_AnenRegnen(self): + # Arrange + val = [0.03999999999999915, 0.0, 0.0600000000000005, 0.0, 0.08000000000000007, 0.0600000000000005, 0.0600000000000005, 0.06099999999999994, 1.556000000000001, 0.0400000000000027, 0.03999999999999915, 0.10000000000000142, 0.019999999999999574, 0.03999999999999915, 0.6400000000000006, 0.03999999999999915, 0.03999999999999915, 0.03999999999999915, 0.03999999999999915, 0.0400000000000027, 1.5410000000000004, 0.05999999999999872, 0.03999999999999915, 0.0, 0.0, 0.03999999999999915, 0.0, 1.0869999999999997, 0.13999999999999702, 0.0, 0.019999999999999574, 0.10000000000000142, 0.34550000000000125, 0.08000000000000185, 0.019999999999999574, 0.0, 0.019999999999999574, 6.531000000000002, 0.03999999999999915, 0.0, 0.03999999999999915, 0.060000000000002274, 0.03999999999999915, 0.04099999999999682, 0.03999999999999915, 0.0, 1.7520000000000024, 0.0, 0.03999999999999915, 0.05999999999999517, 0.020000000000003126, 0.0, 0.03999999999999915, 0.0800000000000054, 0.14000000000000057, 0.03999999999999915, 1.7509999999999977, 0.03999999999999915, 0.03999999999999915, 0.04000000000000625, 0.060000000000002274, 0.0, 0.11299999999999955, 0.09999999999999432, 0.03999999999999915, 0.05999999999999517, 0.01999999999999602, 0.0, 0.9639999999999986, 0.03999999999999915, 0.03999999999999915, 0.01999999999999602, 0.03999999999999915, 0.060000000000002274, 0.0, 0.01999999999999602, 0.05999999999999517, 0.0799999999999983, 0.03999999999999915, 1.8969999999999985, 0.0799999999999983, 0.05999999999999517, 0.0, 0.03999999999999915, 0.0, 0.09999999999999432, 1.3980000000000032, 0.0799999999999983, 0.020000000000003126, 0.0, 0.03999999999999915, 0.0, 0.0800000000000054, 0.01999999999999602, 0.06000000000000938, 0.060000000000002274, 0.0, 2.1199999999999903, 0.03999999999999204, 0.10000000000000853, 0.01999999999999602, 0.03999999999999204, 0.5179999999999865, 0.060000000000002274, 0.01999999999999602, 0.04000000000000625, 0.04000000000000625, 0.04000000000000625, 1.3790000000000049, 0.01999999999999602, 0.03999999999999204, 0.0, 0.0, 0.03999999999999204, 0.0, 1.024000000000001, 0.14000000000000057, 0.0, 0.01999999999999602, 0.10000000000000853, -0.1909999999999883, 0.3719999999999999, 0.0799999999999983, 0.01999999999999602, 0.0, 0.03999999999999204, 17.049000000000007, 0.01999999999999602, 0.0, 0.04000000000000625, 0.03999999999999204, 0.03999999999999204, 0.01999999999999602, 0.04000000000000625, 0.29649999999999466, 0.060000000000002274, 0.04000000000000625, 0.04000000000000625, 0.0, 0.03999999999999204, 0.0, 0.0799999999999983, 0.03999999999999204, 0.04000000000000625, 0.060000000000002274, 0.04000000000000625, 0.3200000000000074, 0.04000000000000625, 0.0, 0.060000000000002274, 0.0, 0.01999999999999602, 0.12000000000000455, 0.04000000000000625, 0.0799999999999983, 0.0, 0.01999999999999602, 0.03999999999999204, 0.5090000000000003, 0.03999999999999204, 0.0, 0.04000000000000625, 0.05999999999998806, 0.0, 0.37400000000000944, 0.01999999999999602, 0.04000000000000625, 0.03999999999999204, 0.0799999999999983, 0.060000000000002274, 0.04000000000000625, 0.021000000000000796, 0.03999999999999204, 0.0, 0.0, 0.09999999999999432, 0.0, 0.936000000000007, 0.04000000000000625, 0.0, 0.01999999999999602, 0.060000000000002274, 0.2670000000000101, 0.03999999999999204, 0.0, 0.03999999999999204, 0.0, 0.09999999999999432, 1.4819999999999993, 0.04000000000000625, 0.01999999999999602, 0.0, 0.060000000000002274, 0.0, 0.0799999999999983, 0.03999999999999204, 0.060000000000002274, 0.060000000000002274, 0.0, 2.5289999999999964, 0.040000000000020464, 0.0, 0.03999999999999204, 0.8095000000000141, 0.03999999999999204, 0.03999999999999204, 0.020000000000010232, 0.37999999999999545, 1.2280000000000086, 0.0, 0.03999999999999204, 0.0, 0.0, 0.2599999999999909, 1.7789999999999964, 0.060000000000002274, 0.040000000000020464, 0.0, 0.03999999999999204, 0.0, 0.20000000000001705, 0.01999999999998181, 0.07999999999998408, 0.07999999999998408, 6.7309999999999945, 0.060000000000002274, 0.12699999999998113, 0.0, 0.060000000000002274, 0.0, 0.09999999999999432, 0.060000000000002274, 0.17000000000001592, 0.0800000000000125, 0.14599999999998658, 2.466000000000008, 0.060000000000002274, 0.19999999999998863, 0.020000000000010232, 0.15500000000000114, 0.9489999999999839, 0.040000000000020464, 0.0, 0.03999999999999204, 0.040000000000020464, 0.14500000000001023] + + # Act + result = deviation(val) + + # Assert + self.assertGreaterEqual(result, 0.15) + self.assertLessEqual(result, 0.35) + + def test_most_common_silent_part_discw(self): + # Arrange + val = [0.08000000000000007, 0.08000000000000007, 0.17999999999999972, 0.03999999999999915, 0.0, 0.0600000000000005, 0.0, 1.3010000000000002, 0.0600000000000005, 0.08000000000000007, 0.08000000000000007, 0.120000000000001, 0.019999999999999574, 0.08000000000000007, 1.6209999999999987, 0.0, 0.09999999999999787, 0.18100000000000094, 0.11999999999999744, 1.1210000000000022, 0.0799999999999983, 0.4209999999999994, 0.0, 0.0, 0.1999999999999993, 0.9000000000000021, 0.23999999999999844, 1.7409999999999997, 0.05999999999999872, 0.10000000000000142, 0.03999999999999915, 0.03999999999999915, 0.08000000000000185, 1.5809999999999995, 0.12000000000000455, 0.03999999999999915, 0.10000000000000142, 0.060000000000002274, 1.561, 0.05999999999999517, 0.01999999999999602, 0.09999999999999432, 0.05999999999999517, 0.03999999999999915, 0.0799999999999983, 0.5399999999999991, 0.5, 0.10000000000000142, 1.3810000000000002, 0.020000000000003126, 0.0799999999999983, 0.0, 0.1010000000000062, 0.060000000000002274, 1.561, 0.060000000000002274, 0.060000000000002274, 0.03999999999999915, 0.0, 0.03999999999999915, 0.14100000000000534, 1.061, 0.05999999999999517, 0.0799999999999983, 0.060000000000002274, 0.0, 0.04000000000000625, 0.10000000000000142, 2.182000000000002, 0.03999999999999915, 0.03999999999999915, 0.35999999999999943, 0.04000000000000625, 0.11999999999999744, 0.17999999999999972, 0.10000000000000142, 0.14000000000000057, 0.5600000000000023, 0.03999999999999915, 0.17999999999999972, 0.11999999999999744, 0.060000000000002274, 1.2809999999999988, 0.12000000000000455, 0.14000000000000057, 0.12000000000000455, 0.020000000000010232, 0.29999999999999716, 1.4810000000000088, 0.03999999999999204, 0.060000000000002274, 0.10000000000000853, 0.04000000000000625, 0.18000000000000682, 0.8400000000000034, 0.12000000000000455, 0.16100000000000136, 0.060000000000002274, 0.0799999999999983, 1.2609999999999957, 0.14000000000000057, 0.10000000000000853, 0.060000000000002274, 0.0, 0.14000000000000057, 0.5400000000000063, 0.3400000000000034, 0.20000000000000284, 1.5319999999999965, 0.09999999999999432, 0.06099999999999284, 0.060000000000002274, 0.14100000000000534, 0.9410000000000025, 0.0799999999999983, 0.0799999999999983, 0.12000000000000455, 0.0, 0.0799999999999983, 1.0009999999999906, 0.060000000000002274, 0.060000000000002274, 0.0799999999999983, 0.0799999999999983, 0.03999999999999204, 0.0799999999999983, 0.0799999999999983, 0.8810000000000002, 1.7019999999999982, 0.0, 0.060000000000002274, 0.03999999999999204, 0.060000000000002274, 0.0799999999999983, 0.9410000000000025, 0.1599999999999966, 0.060000000000002274, 0.09999999999999432, 0.09999999999999432, 0.6800000000000068, 0.22100000000000364, 0.04000000000000625, 0.060000000000002274, 0.6599999999999966, 0.060000000000002274, 0.11999999999999034, 0.14000000000000057, 0.06100000000000705, 8.11699999999999, 0.19999999999998863, 0.6199999999999903, 0.29999999999999716, 0.020000000000010232, 0.05999999999998806, 0.0799999999999983, 0.04000000000000625, 0.0, 2.021000000000001, 0.10000000000000853, 0.12000000000000455, 0.09999999999999432, 0.060000000000002274, 0.01999999999999602, 2.1809999999999974, 0.09999999999999432, 0.060000000000002274, 0.0, 0.12000000000000455, 0.01999999999999602, 0.9200000000000017, 0.9809999999999945, 0.28000000000000114, 0.18000000000000682, 0.2400000000000091, 0.020000000000010232, 0.03999999999999204, 0.12000000000000455, 0.0, 0.0800000000000125, 0.01999999999998181, 0.0800000000000125, 1.460000000000008, 0.07999999999998408, 0.1599999999999966, 0.0, 0.0800000000000125, 0.07999999999998408, 1.6099999999999852, 0.14000000000001478, 0.0800000000000125, 0.09999999999999432, 0.07999999999998408, 0.060000000000002274, 0.0, 3.062000000000012, 0.1799999999999784, 0.12000000000000455, 0.21999999999999886, 0.10000000000002274, 0.07999999999998408, 1.0009999999999764, 0.060000000000002274, 0.12000000000000455, 0.13999999999998636, 0.060000000000002274, 0.18000000000000682, 0.6200000000000045, 0.10000000000002274, 0.040000000000020464, 0.18000000000000682, 0.0800000000000125, 0.060000000000002274, 0.37999999999999545, 0.07999999999998408, 0.060000000000002274, 2.1619999999999777, 0.14000000000001478, 0.07999999999998408, 0.01999999999998181, 0.4199999999999875, 0.12000000000000455, 0.6200000000000045, 0.09999999999999432, 6.356999999999999, 0.03999999999999204, 0.14099999999999113] + + # Act + result = deviation(val) + + # Assert + self.assertGreaterEqual(result, 0.24) + self.assertLessEqual(result, 0.43) + + def test_most_common_silent_part_kumr(self): + # Arrange + + val = [0.16800000000000104, 0.019999999999999574, 0.019999999999999574, 0.0, 0.03999999999999915, 0.0, 0.0600000000000005, 0.040000000000000924, 0.5960000000000001, 0.03999999999999915, 0.0, 0.040000000000000924, 0.019999999999999574, 0.019999999999999574, 0.03999999999999915, 0.0, 0.019999999999999574, 0.0, 0.03999999999999915, 0.0, 0.05999999999999872, 0.0, 0.03999999999999915, 0.0, 0.019999999999999574, 0.0, 0.0, 0.0, 0.019999999999999574, 0.019999999999999574, 0.0400000000000027, 0.0, 0.03999999999999915, 0.0, 0.0400000000000027, 0.10899999999999821, 0.019999999999999574, 0.019999999999999574, 0.14700000000000202, 0.0, 0.0, 0.019999999999999574, 0.020000000000003126, 0.03999999999999915, 0.3069999999999986, 0.0400000000000027, 0.03999999999999915, 0.0400000000000027, 0.13100000000000023, 0.03999999999999915, 0.03999999999999915, 0.0, 0.0, 0.019999999999999574, 0.09299999999999997, 0.3719999999999999, 0.03999999999999915, 0.0400000000000027, 0.0, 0.10400000000000276, 0.019999999999999574, 0.0400000000000027, 0.0, 0.03999999999999915, 0.0, 0.05999999999999872, 0.0, 0.0400000000000027, 0.0, 0.03999999999999915, 0.03999999999999915, 0.0, 0.0, 0.0, 0.03999999999999915, 0.11199999999999832, 0.03999999999999915, 0.019999999999999574, 0.0400000000000027, 0.0, 0.0, 0.0, 0.060000000000002274, 0.1600000000000037, 0.03999999999999915, 0.0, 0.21699999999999875, 0.0, 0.03999999999999915, 0.03999999999999915, 0.05999999999999517, 0.020000000000003126, 0.01999999999999602, 0.03999999999999915, 0.0, 0.03999999999999915, 0.0800000000000054, 0.19200000000000017, 0.01999999999999602, 0.03999999999999915, 0.0, 0.03999999999999915, 0.0, 0.03999999999999915, 0.03999999999999915, 0.020000000000003126, 0.0, 0.03999999999999915, 0.0, 0.04000000000000625, 1.9950000000000045, 0.03999999999999915, 0.03999999999999915, 0.0, 0.03999999999999915, 0.0, 0.021000000000000796, 0.0, 0.45700000000000074, 0.03999999999999915, 0.0, 0.03999999999999915, 0.020000000000003126, 0.03999999999999915, 0.0, 0.060000000000002274, 0.03999999999999915, 0.03999999999999915, 0.0, 0.03999999999999915, 0.03999999999999915, 0.03999999999999915, 0.03999999999999915, 0.060000000000002274, 0.020000000000003126, 0.020000000000003126, 0.0, 0.01999999999999602, 0.05999999999999517, 0.0, 0.2959999999999994, 0.04000000000000625, 0.04000000000000625, 0.01999999999999602, 0.03999999999999915, 0.0, 0.0, 0.03999999999999915, 0.03999999999999915, 0.0, 0.060000000000002274, 0.0, 0.03999999999999915, 0.01999999999999602, 1.8879999999999981, 0.03999999999999915, 0.0, 0.03999999999999915, 0.03999999999999915, 0.03999999999999915, 0.03999999999999915, 0.03999999999999915, 0.05999999999999517, 0.10000000000000142, 0.09999999999999432, 0.060000000000002274, 0.060000000000002274, 0.0, 0.05999999999999517, 0.1630000000000038, 1.509999999999998, 0.03999999999999915, 0.0, 0.04000000000000625, 0.03999999999999915, 0.0, 0.26899999999999835, 0.03999999999999915, 0.0, 0.0, 0.04000000000000625, 0.0, 0.060000000000002274, 0.060000000000002274, 0.0, 0.060000000000002274, 0.03999999999999204, 1.7930000000000064, 0.04099999999999682, 0.0, 0.04099999999999682, 0.06099999999999284, 0.03999999999999204, 0.0, 0.04000000000000625, 0.04000000000000625, 0.03999999999999204, 0.020000000000010232, 0.04099999999999682, 0.04000000000000625, 0.0, 0.04099999999999682, 0.060000000000002274, 0.0, 0.03999999999999204, 0.03999999999999204, 1.5649999999999977, 0.01999999999999602, 0.04000000000000625, 0.04000000000000625, 0.03999999999999204, 0.04000000000000625, 0.05999999999998806, 0.06100000000000705, 0.0, 0.060000000000002274, 0.060000000000002274, 28.479, 0.03999999999999204, 0.04000000000000625, 0.0, 0.04000000000000625, 0.0, 0.03999999999999204, 0.0, 0.0, 0.060000000000002274, 0.0, 0.03999999999999204, 0.03999999999999204, 0.03999999999999204, 0.0, 0.03999999999999204, 0.04000000000000625, 0.04000000000000625, 0.0, 0.03999999999999204, 0.03999999999999204, 0.03999999999999204, 0.04000000000000625, 0.04099999999999682, 0.01999999999999602, 0.01999999999999602, 0.0, 0.01999999999999602, 0.05999999999998806, 0.0, 0.0, 0.03999999999999204, 0.04000000000000625, 0.01999999999999602, 0.12000000000000455, 0.01999999999999602, 0.04000000000000625, 0.04000000000000625, 0.03999999999999204, 0.0, 0.0, 0.04000000000000625, 0.04000000000000625, 0.0, 10.948999999999998, 0.0, 0.040000000000020464, 0.020000000000010232, 2.0900000000000034, 0.03999999999999204, 0.0, 0.020000000000010232, 0.03999999999999204, 0.03999999999999204, 0.01999999999998181, 0.040000000000020464, 0.060000000000002274, 0.09999999999999432, 0.020000000000010232, 0.0800000000000125, 0.03999999999999204, 0.0, 0.03999999999999204, 0.01999999999998181, 1.5370000000000061, 0.040000000000020464, 0.0, 0.03999999999999204, 0.060000000000002274, 0.0, 0.03999999999999204, 0.040000000000020464, 0.0, 0.0, 0.020000000000010232, 0.0, 0.0800000000000125, 0.03999999999999204, 0.0, 0.03999999999999204, 0.040000000000020464, 0.7199999999999989, 0.14599999999998658, 0.040000000000020464, 0.0, 0.03999999999999204, 0.060000000000002274, 0.03999999999999204, 0.0, 0.03999999999999204, 0.03999999999999204, 0.03999999999999204, 0.020000000000010232, 0.05999999999997385, 0.040000000000020464, 0.0, 0.060000000000002274, 0.020000000000010232, 0.0, 0.01999999999998181, 0.01999999999998181, 1.1400000000000148, 0.21199999999998909, 0.040000000000020464, 0.03999999999999204, 0.03999999999999204, 0.0, 0.060000000000002274, 0.060000000000002274, 0.06099999999997863, 0.0, 0.040000000000020464, 0.01999999999998181, 0.040000000000020464, 0.0, 0.060000000000002274, 0.060000000000002274, 5.156000000000006, 0.0, 0.020000000000010232, 0.020000000000010232, 0.020000000000010232, 0.060000000000002274, 0.0, 0.040000000000020464, 0.040000000000020464, 0.05999999999997385, 0.0, 0.060000000000002274, 0.03999999999999204, 0.020000000000010232, 0.020000000000010232, 0.0, 0.040000000000020464, 0.060000000000002274, 0.040000000000020464, 0.0, 0.03999999999999204, 0.03999999999999204, 0.060000000000002274, 0.020000000000010232, 0.060000000000002274, 0.040000000000020464, 0.0, 0.03999999999999204, 0.060000000000002274, 0.0, 0.060000000000002274, 0.040000000000020464, 0.25499999999999545, 0.03999999999999204, 0.020000000000010232, 0.01999999999998181, 0.0, 0.060000000000002274, 0.060000000000002274, 0.060000000000002274, 0.0, 0.05999999999997385, 0.040000000000020464, 0.060000000000002274, 0.0, 0.060000000000002274, 0.01999999999998181] + + # Act + result = deviation(val) + + # Assert + self.assertGreaterEqual(result, 0.11) + self.assertLessEqual(result, 0.168) + if __name__ == "__main__": unittest.main() \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index ffa4430..3057b4e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -18,7 +18,6 @@ tensorflow<2.11 tqdm~=4.65.2 whisperx~=3.1.1 yt_dlp~=2023.9.24 - isort~=5.12 black~=23.3 pylint~=2.17 diff --git a/src/Settings.py b/src/Settings.py index e592af7..893fb58 100644 --- a/src/Settings.py +++ b/src/Settings.py @@ -1,5 +1,5 @@ class Settings: - APP_VERSION = "0.0.10" + APP_VERSION = "0.0.11-dev1" create_midi = True create_plot = False diff --git a/src/modules/Ultrastar/ultrastar_writer.py b/src/modules/Ultrastar/ultrastar_writer.py index 71874fc..7158045 100644 --- a/src/modules/Ultrastar/ultrastar_writer.py +++ b/src/modules/Ultrastar/ultrastar_writer.py @@ -1,39 +1,51 @@ """Ultrastar writer module""" import re -from packaging import version import langcodes +from packaging import version from modules.console_colors import ULTRASINGER_HEAD from modules.Ultrastar.ultrastar_converter import ( real_bpm_to_ultrastar_bpm, second_to_beat, + beat_to_second, ) from modules.Ultrastar.ultrastar_txt import UltrastarTxtValue, UltrastarTxtTag, UltrastarTxtNoteTypeTag, \ FILE_ENCODING from modules.Speech_Recognition.TranscribedData import TranscribedData from modules.Ultrastar.ultrastar_score_calculator import Score + +def get_thirtytwo_note_second(real_bpm: float): + """Converts a beat to a 1/32 note in second""" + return 60 / real_bpm / 8 + + def get_sixteenth_note_second(real_bpm: float): """Converts a beat to a 1/16 note in second""" return 60 / real_bpm / 4 + def get_eighth_note_second(real_bpm: float): """Converts a beat to a 1/8 note in second""" return 60 / real_bpm / 2 + def get_quarter_note_second(real_bpm: float): """Converts a beat to a 1/4 note in second""" return 60 / real_bpm + def get_half_note_second(real_bpm: float): """Converts a beat to a 1/2 note in second""" return 60 / real_bpm * 2 + def get_whole_note_second(real_bpm: float): """Converts a beat to a 1/1 note in second""" return 60 / real_bpm * 4 + def get_multiplier(real_bpm: float) -> int: """Calculates the multiplier for the BPM""" @@ -47,6 +59,7 @@ def get_multiplier(real_bpm: float) -> int: multiplier += 1 return multiplier - 2 + def get_language_name(language: str) -> str: """Creates the language name from the language code""" @@ -58,7 +71,7 @@ def create_ultrastar_txt_from_automation( note_numbers: list[int], ultrastar_file_output: str, ultrastar_class: UltrastarTxtValue, - bpm=120, + real_bpm=120, ) -> None: """Creates an Ultrastar txt file from the automation data""" @@ -66,10 +79,10 @@ def create_ultrastar_txt_from_automation( f"{ULTRASINGER_HEAD} Creating {ultrastar_file_output} from transcription." ) - ultrastar_bpm = real_bpm_to_ultrastar_bpm(bpm) + ultrastar_bpm = real_bpm_to_ultrastar_bpm(real_bpm) multiplication = get_multiplier(ultrastar_bpm) ultrastar_bpm = ultrastar_bpm * get_multiplier(ultrastar_bpm) - silence_split_duration = get_sixteenth_note_second(bpm) + silence_split_duration = calculate_silent_beat_length(transcribed_data) with open(ultrastar_file_output, "w", encoding=FILE_ENCODING) as file: gap = transcribed_data[0].start @@ -103,18 +116,26 @@ def create_ultrastar_txt_from_automation( # Write the singing part previous_end_beat = 0 + separated_word_silence = [] # This is a workaround for separated words that get his ends to far away + for i, data in enumerate(transcribed_data): start_time = (data.start - gap) * multiplication end_time = ( data.end - data.start ) * multiplication - start_beat = round(second_to_beat(start_time, bpm)) - duration = round(second_to_beat(end_time, bpm)) + start_beat = round(second_to_beat(start_time, real_bpm)) + duration = round(second_to_beat(end_time, real_bpm)) # Fix the round issue, so the beats don’t overlap start_beat = max(start_beat, previous_end_beat) previous_end_beat = start_beat + duration + # Calculate the silence between the words + if i < len(transcribed_data) - 1: + silence = (transcribed_data[i + 1].start - data.end) + else: + silence = 0 + # : 10 10 10 w # ':' start midi part # 'n1' start at real beat @@ -126,33 +147,55 @@ def create_ultrastar_txt_from_automation( f"{str(duration)} " \ f"{str(note_numbers[i])} " \ f"{data.word}\n" + file.write(line) # detect silence between words if not transcribed_data[i].is_word_end: + separated_word_silence.append(silence) continue - if i < len(transcribed_data) - 1: - silence = ( - transcribed_data[i + 1].start - data.end - ) - else: - silence = 0 - - if silence > silence_split_duration and i != len(transcribed_data) - 1: + if silence_split_duration != 0 and silence > silence_split_duration or any( + s > silence_split_duration for s in separated_word_silence) and i != len(transcribed_data) - 1: # - 10 # '-' end of current sing part # 'n1' show next at time in real beat show_next = ( - second_to_beat(data.end - gap, bpm) + second_to_beat(data.end - gap, real_bpm) * multiplication ) linebreak = f"{UltrastarTxtTag.LINEBREAK} " \ f"{str(round(show_next))}\n" file.write(linebreak) + separated_word_silence = [] file.write(f"{UltrastarTxtTag.FILE_END}") +def deviation(silence_parts): + """Calculates the deviation of the silence parts""" + + if len(silence_parts) < 5: + return 0 + + # Remove the longest part so the deviation is not that high + sorted_parts = sorted(silence_parts) + filtered_parts = [part for part in sorted_parts if part < sorted_parts[-1]] + + mean = sum(filtered_parts) / len(filtered_parts) + return mean + + +def calculate_silent_beat_length(transcribed_data: list[TranscribedData]): + print(f"{ULTRASINGER_HEAD} Calculating silence parts for linebreaks.") + + silent_parts = [] + for i, data in enumerate(transcribed_data): + if i < len(transcribed_data) - 1: + silent_parts.append(transcribed_data[i + 1].start - data.end) + + return deviation(silent_parts) + + def create_repitched_txt_from_ultrastar_data( input_file: str, note_numbers: list[int], output_repitched_ultrastar: str ) -> None: