diff --git a/.gitignore b/.gitignore index f6e4cf2b..8e643496 100644 --- a/.gitignore +++ b/.gitignore @@ -141,7 +141,7 @@ cython_debug/ # additional files tests/**/*.wav -!tests/dataset_raw/44k/34j/**/*.wav +!tests/dataset_raw/34j/**/*.wav tests/**/*.npy tests/**/*.pt tests/**/*.txt diff --git a/notebooks/so-vits-svc-fork-4.0.ipynb b/notebooks/so-vits-svc-fork-4.0.ipynb index 5d5c7c82..3125e1de 100644 --- a/notebooks/so-vits-svc-fork-4.0.ipynb +++ b/notebooks/so-vits-svc-fork-4.0.ipynb @@ -80,7 +80,7 @@ "metadata": {}, "outputs": [], "source": [ - "!mkdir -p \"dataset_raw/44k\"" + "!mkdir -p \"dataset_raw\"" ] }, { @@ -89,7 +89,7 @@ "metadata": {}, "outputs": [], "source": [ - "#!rm -r \"dataset_raw/44k\"\n", + "#!rm -r \"dataset_raw\"\n", "#!rm -r \"dataset/44k\"" ] }, @@ -101,7 +101,7 @@ "source": [ "#@title Copy your dataset\n", "DATASET_NAME = \"kiritan\" #@param {type: \"string\"}\n", - "!cp -R /content/drive/MyDrive/so-vits-svc-fork/dataset/{DATASET_NAME}/ -t \"dataset_raw/44k/\"" + "!cp -R /content/drive/MyDrive/so-vits-svc-fork/dataset/{DATASET_NAME}/ -t \"dataset_raw/\"" ] }, { @@ -114,7 +114,7 @@ "#@markdown Make sure you agree to the license when using this dataset.\n", "# !wget https://tyc.rei-yumesaki.net/files/sozai-tyc-corpus1.zip\n", "# !unzip sozai-tyc-corpus1.zip\n", - "# !mv \"/content/つくよみちゃんコーパス Vol.1 声優統計コーパス(JVSコーパス準拠)/おまけ:WAV(+12dB増幅&高音域削減)/WAV(+12dB増幅&高音域削減)\" \"dataset_raw/44k/tsukuyomi\"" + "# !mv \"/content/つくよみちゃんコーパス Vol.1 声優統計コーパス(JVSコーパス準拠)/おまけ:WAV(+12dB増幅&高音域削減)/WAV(+12dB増幅&高音域削減)\" \"dataset_raw/tsukuyomi\"" ] }, { diff --git a/src/so_vits_svc_fork/__main__.py b/src/so_vits_svc_fork/__main__.py index b247ccb6..2fac2469 100644 --- a/src/so_vits_svc_fork/__main__.py +++ b/src/so_vits_svc_fork/__main__.py @@ -371,7 +371,7 @@ def vc( "-i", "--input-dir", type=click.Path(exists=True), - default=Path("./dataset_raw/44k"), + default=Path("./dataset_raw"), help="path to source dir", ) @click.option( diff --git a/src/so_vits_svc_fork/preprocess_resample.py b/src/so_vits_svc_fork/preprocess_resample.py index 188d957f..c3302444 100644 --- a/src/so_vits_svc_fork/preprocess_resample.py +++ b/src/so_vits_svc_fork/preprocess_resample.py @@ -1,5 +1,6 @@ from __future__ import annotations +import warnings from logging import getLogger from pathlib import Path from typing import Iterable @@ -35,6 +36,17 @@ def _get_unique_filename(path: Path, existing_paths: Iterable[Path]) -> Path: i += 1 +def is_relative_to(path: Path, *other): + """Return True if the path is relative to another path or False. + Python 3.9+ has Path.is_relative_to() method, but we need to support Python 3.8. + """ + try: + path.relative_to(*other) + return True + except ValueError: + return False + + def preprocess_resample( input_dir: Path | str, output_dir: Path | str, sampling_rate: int ) -> None: @@ -71,6 +83,17 @@ def preprocess_one(input_path: Path, output_path: Path) -> None: out_paths = [] for in_path in input_dir.rglob("*.*"): in_path_relative = in_path.relative_to(input_dir) + if not in_path.is_absolute() and is_relative_to( + in_path, Path("dataset_raw") / "44k" + ): + new_in_path_relative = in_path_relative.relative_to("44k") + warnings.warn( + f"Recommended folder structure has changed since v1.0.0. " + "Please move your dataset directly under dataset_raw folder. " + f"Recoginzed {in_path_relative} as {new_in_path_relative}" + ) + in_path_relative = new_in_path_relative + if len(in_path_relative.parts) < 2: continue speaker_name = in_path_relative.parts[0] diff --git a/tests/dataset_raw/44k/34j/1.wav b/tests/dataset_raw/34j/nested/1.wav similarity index 100% rename from tests/dataset_raw/44k/34j/1.wav rename to tests/dataset_raw/34j/nested/1.wav diff --git a/tests/dataset_raw/44k/34j/nested/10.wav b/tests/dataset_raw/34j/nested/10.wav similarity index 100% rename from tests/dataset_raw/44k/34j/nested/10.wav rename to tests/dataset_raw/34j/nested/10.wav diff --git a/tests/dataset_raw/44k/34j/nested/2.wav b/tests/dataset_raw/34j/nested/2.wav similarity index 100% rename from tests/dataset_raw/44k/34j/nested/2.wav rename to tests/dataset_raw/34j/nested/2.wav diff --git a/tests/dataset_raw/44k/34j/nested/3.wav b/tests/dataset_raw/34j/nested/3.wav similarity index 100% rename from tests/dataset_raw/44k/34j/nested/3.wav rename to tests/dataset_raw/34j/nested/3.wav diff --git a/tests/dataset_raw/44k/34j/nested/4.wav b/tests/dataset_raw/34j/nested/4.wav similarity index 100% rename from tests/dataset_raw/44k/34j/nested/4.wav rename to tests/dataset_raw/34j/nested/4.wav diff --git a/tests/dataset_raw/44k/34j/nested/5.wav b/tests/dataset_raw/34j/nested/5.wav similarity index 100% rename from tests/dataset_raw/44k/34j/nested/5.wav rename to tests/dataset_raw/34j/nested/5.wav diff --git a/tests/dataset_raw/44k/34j/nested/6.wav b/tests/dataset_raw/34j/nested/6.wav similarity index 100% rename from tests/dataset_raw/44k/34j/nested/6.wav rename to tests/dataset_raw/34j/nested/6.wav diff --git a/tests/dataset_raw/44k/34j/nested/7.wav b/tests/dataset_raw/34j/nested/7.wav similarity index 100% rename from tests/dataset_raw/44k/34j/nested/7.wav rename to tests/dataset_raw/34j/nested/7.wav diff --git a/tests/dataset_raw/44k/34j/nested/8.wav b/tests/dataset_raw/34j/nested/8.wav similarity index 100% rename from tests/dataset_raw/44k/34j/nested/8.wav rename to tests/dataset_raw/34j/nested/8.wav diff --git a/tests/dataset_raw/44k/34j/nested/9.wav b/tests/dataset_raw/34j/nested/9.wav similarity index 100% rename from tests/dataset_raw/44k/34j/nested/9.wav rename to tests/dataset_raw/34j/nested/9.wav diff --git a/tests/dataset_raw/44k/34j/11.wav b/tests/dataset_raw/44k/34j/11.wav deleted file mode 100644 index 49dbbdd9..00000000 Binary files a/tests/dataset_raw/44k/34j/11.wav and /dev/null differ diff --git a/tests/dataset_raw/44k/34j/12.wav b/tests/dataset_raw/44k/34j/12.wav deleted file mode 100644 index 16ebe39b..00000000 Binary files a/tests/dataset_raw/44k/34j/12.wav and /dev/null differ diff --git a/tests/dataset_raw/44k/34j/13.wav b/tests/dataset_raw/44k/34j/13.wav deleted file mode 100644 index 117b3067..00000000 Binary files a/tests/dataset_raw/44k/34j/13.wav and /dev/null differ diff --git a/tests/dataset_raw/44k/34j/14.wav b/tests/dataset_raw/44k/34j/14.wav deleted file mode 100644 index 835d0087..00000000 Binary files a/tests/dataset_raw/44k/34j/14.wav and /dev/null differ diff --git a/tests/dataset_raw/44k/34j/15.wav b/tests/dataset_raw/44k/34j/15.wav deleted file mode 100644 index f5faa6a2..00000000 Binary files a/tests/dataset_raw/44k/34j/15.wav and /dev/null differ diff --git a/tests/dataset_raw/44k/34j/16.wav b/tests/dataset_raw/44k/34j/16.wav deleted file mode 100644 index 2a1d8d28..00000000 Binary files a/tests/dataset_raw/44k/34j/16.wav and /dev/null differ diff --git a/tests/dataset_raw/44k/34j/17.wav b/tests/dataset_raw/44k/34j/17.wav deleted file mode 100644 index c2d976c4..00000000 Binary files a/tests/dataset_raw/44k/34j/17.wav and /dev/null differ diff --git a/tests/dataset_raw/44k/34j/18.wav b/tests/dataset_raw/44k/34j/18.wav deleted file mode 100644 index cda8627f..00000000 Binary files a/tests/dataset_raw/44k/34j/18.wav and /dev/null differ diff --git a/tests/dataset_raw/44k/34j/19.wav b/tests/dataset_raw/44k/34j/19.wav deleted file mode 100644 index d3043f8e..00000000 Binary files a/tests/dataset_raw/44k/34j/19.wav and /dev/null differ diff --git a/tests/dataset_raw/44k/34j/20.wav b/tests/dataset_raw/44k/34j/20.wav deleted file mode 100644 index e1af9aec..00000000 Binary files a/tests/dataset_raw/44k/34j/20.wav and /dev/null differ diff --git a/tests/dataset_raw/44k/34j/nested/1.wav b/tests/dataset_raw/44k/34j/nested/1.wav deleted file mode 100644 index 1c12ee00..00000000 Binary files a/tests/dataset_raw/44k/34j/nested/1.wav and /dev/null differ diff --git a/tests/dataset_raw/44k/34j/nested2/1.wav b/tests/dataset_raw/44k/34j/nested2/1.wav deleted file mode 100644 index 1c12ee00..00000000 Binary files a/tests/dataset_raw/44k/34j/nested2/1.wav and /dev/null differ diff --git a/tests/test_main.py b/tests/test_main.py index 0e9a351f..87b26ee5 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -22,14 +22,13 @@ def test_infer(self): raise SkipTest("Skip inference test on CI") from so_vits_svc_fork.inference_main import infer # noqa - # infer("tests/dataset_raw/44k/34j/1.wav", "tests/configs/config.json", "tests/logs/44k") + # infer("tests/dataset_raw/34j/1.wav", "tests/configs/config.json", "tests/logs/44k") def test_preprocess(self): from so_vits_svc_fork.preprocess_resample import preprocess_resample - preprocess_resample("tests/dataset_raw/44k", "tests/dataset/44k", 44100) + preprocess_resample("tests/dataset_raw", "tests/dataset/44k", 44100) - def test_preprocess_config(self): from so_vits_svc_fork.preprocess_flist_config import preprocess_config preprocess_config( @@ -40,9 +39,8 @@ def test_preprocess_config(self): "tests/configs/config.json", ) - def test_preprocess_hubert(self): if IS_CI: - raise SkipTest("Skip preprocessing test on CI") + raise SkipTest("Skip hubert and f0 test on CI") from so_vits_svc_fork.preprocess_hubert_f0 import preprocess_hubert_f0 preprocess_hubert_f0("tests/dataset/44k", "tests/configs/44k/config.json")