Skip to content

Commit

Permalink
Merge pull request #162 from rakuri255/refactor/class-refactorings
Browse files Browse the repository at this point in the history
Refactor/class refactorings
  • Loading branch information
rakuri255 authored Jul 27, 2024
2 parents 158f914 + 63d14bc commit 33e5f3c
Show file tree
Hide file tree
Showing 38 changed files with 2,286 additions and 1,121 deletions.
3 changes: 2 additions & 1 deletion ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Version: 0.0.12
Date: 2024.07.07
Date: 2024.07.13
- Changes:
- Reduce Memory usage by clearing cache in whisper
- Added lyrics to midi file
- Some bug fixes and improved error handling and logs
- Fix hypen language download

Expand Down
16 changes: 16 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
[build-system]
requires = ["setuptools", "setuptools-scm"]
build-backend = "setuptools.build_meta"

[project]
requires-python = "3.10"
name = "UltraSinger"
dynamic = ["dependencies", "optional-dependencies"]

[tool.setuptools.dynamic]
dependencies = { file = ["requirements.in"] }
optional-dependencies.test = { file = ["requirements-test.txt"] }

[project.optional-dependencies]
dev = ["pytest"]

[tool.isort]
profile = "black"
[tool.pytest.ini_options]
Expand Down
4 changes: 2 additions & 2 deletions pytest/modules/Audio/test_denoise.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import os
import unittest
from src.modules.Audio.denoise import ffmpeg_reduce_noise
from src.modules.Audio.denoise import denoise_vocal_audio
import pytest


Expand All @@ -17,7 +17,7 @@ def test_ffmpeg_reduce_noise(self):
test_output = test_dir + "/test_output"

# Act
ffmpeg_reduce_noise(test_file_abs_path, test_output + "/output_" + test_file_name)
denoise_vocal_audio(test_file_abs_path, test_output + "/output_" + test_file_name)


if __name__ == "__main__":
Expand Down
6 changes: 3 additions & 3 deletions pytest/modules/Speech_Recognition/test_hyphenation.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from src.modules.Speech_Recognition.hyphenation import hyphenation, language_check
from hyphen import Hyphenator


class TestHypenation(unittest.TestCase):

def test_hypenation(self):
Expand All @@ -17,18 +18,17 @@ def test_hypenation(self):

@patch('hyphen.dictools.list_installed')
def test_language_check_has_installed_language(self, mock_list_installed):

mock_list_installed.return_value = ['de', 'de_DE', 'en', 'en_US', 'en_GB']
assert language_check("en") == "en_US"
assert language_check("de") == "de_DE"

@patch('hyphen.dictools.list_installed')
def test_language_check_not_installed_language(self, mock_list_installed):

mock_list_installed.return_value = []
assert language_check("fr") == "fr_FR"
assert language_check("de") == "de"
assert language_check("none") == None


if __name__ == "__main__":
unittest.main()
unittest.main()
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Tests for ultrastar_converter.py"""

from src.modules.Ultrastar.ultrastar_converter import real_bpm_to_ultrastar_bpm
from modules.Ultrastar.coverter.ultrastar_converter import real_bpm_to_ultrastar_bpm


def test_real_bpm_to_ultrastar_bpm():
Expand Down
17 changes: 17 additions & 0 deletions pytest/modules/UltraStar/converter/test_ultrastar_txt_converter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""Tests for ultrastar_txt_converter.py"""

import unittest
from modules.Ultrastar.coverter.ultrastar_txt_converter import extract_year


class TestUltrastarTxtConverter(unittest.TestCase):

def test_extract_year(self):
years = {extract_year("2023-12-31"), extract_year("2023-12-31 23:59:59"), extract_year("2023/12/31"),
extract_year("2023\\12\\31"), extract_year("2023.12.31"), extract_year("2023 12 31"),
extract_year("12-31-2023"), extract_year("12/31/2023"), extract_year("12\\31\\2023"),
extract_year("12.31.2023"), extract_year("12 31 2023"), extract_year("12-2023"),
extract_year("12/2023"), extract_year("2023")}

for year in years:
self.assertEqual(year, "2023")
36 changes: 36 additions & 0 deletions pytest/modules/UltraStar/test_ultrastar_parser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""Tests for ultrastar_parser.py"""

import unittest
import os
from unittest.mock import patch, MagicMock
from modules.Ultrastar.ultrastar_parser import parse_ultrastar_txt


class TestUltraStarParser(unittest.TestCase):
@patch("modules.Ultrastar.ultrastar_parser.parse")
@patch("modules.Ultrastar.ultrastar_parser.os.path.dirname")
@patch("modules.os_helper.create_folder")
def test_parse_ultrastar_txt(self, mock_create_folder, mock_dirname, mock_parse):
# Arrange
mock_parse.return_value = MagicMock(mp3="test.mp3",
artist=" Test Artist ",
# Also test leading and trailing whitespaces
title=" Test Title ") # Also test leading and trailing whitespaces

mock_dirname.return_value = os.path.join("path", "to", "input")
output_file_path = os.path.join("path", "to", "output")

mock_create_folder.return_value = None

# Act
result = parse_ultrastar_txt(mock_dirname.return_value, output_file_path)

# Assert
self.assertEqual(result, ("Test Artist - Test Title",
os.path.join("path", "to", "output", "Test Artist - Test Title"),
os.path.join("path", "to", "input", "test.mp3"),
mock_parse.return_value))
#
mock_parse.assert_called_once()
mock_dirname.assert_called_once()
mock_create_folder.assert_called_once()
Loading

0 comments on commit 33e5f3c

Please sign in to comment.