- voice-changer/: install.bat (uv + Python 3.12 + pinned Applio + torch cu128), VoiceChanger.exe launcher (mingw), tkinter GUI (model list, auto ±12 pitch across genders, mic/output/monitor devices, latency, noise gate), train.bat (preprocess/extract/train/index → models/<id>), examples.bat (Korean example models from KSS + Zeroth-Korean), build-release.sh - consent-recorder: default OPERATOR_NAME=사금향 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
50 lines
1.9 KiB
Python
50 lines
1.9 KiB
Python
"""모델 목록 · 자동 음높이 (엔진 없이 도는 부분). 실행: python -m unittest discover -s voice-changer/tests"""
|
|
import json
|
|
import sys
|
|
import tempfile
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "app"))
|
|
from common import slug # noqa: E402
|
|
from models import auto_pitch, list_models # noqa: E402
|
|
|
|
|
|
def make(root: Path, mid: str, info: dict | None, index=True, pth=True):
|
|
d = root / mid
|
|
d.mkdir()
|
|
if pth:
|
|
(d / "model.pth").write_bytes(b"x")
|
|
if index:
|
|
(d / "model.index").write_bytes(b"x")
|
|
if info is not None:
|
|
(d / "info.json").write_text(json.dumps(info, ensure_ascii=False), encoding="utf-8")
|
|
|
|
|
|
class ModelsTest(unittest.TestCase):
|
|
def test_list_models_orders_own_before_examples_and_skips_broken(self):
|
|
with tempfile.TemporaryDirectory() as t:
|
|
root = Path(t)
|
|
make(root, "example_kss", {"name": "예시 여성 1 (KSS)", "gender": "female", "example": True})
|
|
make(root, "seunghan", {"name": "승한", "gender": "male"}, index=False)
|
|
make(root, "broken", {"name": "pth 없음"}, pth=False)
|
|
make(root, "noinfo", None)
|
|
ms = list_models(root)
|
|
self.assertEqual([m.id for m in ms], ["noinfo", "seunghan", "example_kss"])
|
|
self.assertIsNone(ms[1].index)
|
|
self.assertEqual(ms[1].label, "승한 (남성)")
|
|
self.assertEqual(ms[2].label, "예시 여성 1 (KSS) (여성 · 예시)")
|
|
|
|
def test_auto_pitch_shifts_one_octave_across_genders(self):
|
|
self.assertEqual(auto_pitch("male", "female"), 12)
|
|
self.assertEqual(auto_pitch("female", "male"), -12)
|
|
self.assertEqual(auto_pitch("male", "male"), 0)
|
|
|
|
def test_slug(self):
|
|
self.assertEqual(slug("Seung Han!"), "seung_han")
|
|
self.assertEqual(slug("승한"), "")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|