Repository: voicepaw/so-vits-svc-fork

Issue:
`svc pre-split` command not functional
Found some bugs. After the preprocessing commits from 2.0.0 and up, the command `svc pre-resample -h` will no longer work.

```
(venv) C:\Users\LXC PC\Desktop\sovits\venv\Scripts>svc pre-resample -h
[14:39:02] INFO     [14:39:02] Version: 2.1.0                                                             __main__.py:20
Error: Option '-h' requires an argument.
```

In addition, the command `svc pre-split` does not work as well.

```
(venv) C:\Users\LXC PC\Desktop\sovits\venv\Scripts>svc pre-split -h
[14:55:42] INFO     [14:55:42] Version: 2.1.0                                                             __main__.py:20
Error: Option '-h' requires an argument.
```

```
(venv) C:\Users\LXC PC\Desktop\sovits\venv\Scripts>svc pre-split -i "C:\Users\LXC PC\Desktop\sovits\venv\Scripts\dataset_raw\hapiraw"
[14:56:17] INFO     [14:56:17] Version: 2.1.0                                                             __main__.py:20
Traceback (most recent call last):
  File "C:\Program Files\Python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\LXC PC\Desktop\sovits\venv\Scripts\svc.exe\__main__.py", line 7, in <module>
  File "C:\Users\LXC PC\Desktop\sovits\venv\lib\site-packages\click\core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\LXC PC\Desktop\sovits\venv\lib\site-packages\click\core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "C:\Users\LXC PC\Desktop\sovits\venv\lib\site-packages\click\core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\LXC PC\Desktop\sovits\venv\lib\site-packages\click\core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\LXC PC\Desktop\sovits\venv\lib\site-packages\click\core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "C:\Users\LXC PC\Desktop\sovits\venv\lib\site-packages\so_vits_svc_fork\__main__.py", line 668, in pre_split
    from .preprocess_split import preprocess_split
  File "C:\Users\LXC PC\Desktop\sovits\venv\lib\site-packages\so_vits_svc_fork\preprocess_split.py", line 45, in <module>
    input_dir: Path | str,
TypeError: unsupported operand type(s) for |: 'type' and 'type'
```


Discussion:
That's because `-h` was added as a new flag to `pre-resample` and `pre-split` (probably all `svc` commands)
![image](https://user-images.githubusercontent.com/1345036/227917340-e3263a60-cc18-4836-9435-82730aa78c41.png)
> That's because -h was added as a new flag to pre-resample and pre-split (probably all svc commands)

I see. That explains it. I was using `-h` all along so I didn't notice the change. The README should probably be updated so others won't make the same mistake.

As for the `svc pre-split` command, do you have any idea why it's not working? Tried it on a fresh venv install and it still gives me the same error:

```
(venv) C:\Users\User\Desktop\sovits\venv\Scripts>svc pre-split -i "C:\Users\User\Desktop\testcut" -o "C:\Users\User\Desktop\testcutout"
[18:57:30] INFO     [18:57:30] Version: 2.1.0                                                             __main__.py:20
Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\User\Desktop\sovits\venv\Scripts\svc.exe\__main__.py", line 7, in <module>
  File "C:\Users\User\Desktop\sovits\venv\lib\site-packages\click\core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\User\Desktop\sovits\venv\lib\site-packages\click\core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "C:\Users\User\Desktop\sovits\venv\lib\site-packages\click\core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\User\Desktop\sovits\venv\lib\site-packages\click\core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\User\Desktop\sovits\venv\lib\site-packages\click\core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "C:\Users\User\Desktop\sovits\venv\lib\site-packages\so_vits_svc_fork\__main__.py", line 668, in pre_split
    from .preprocess_split import preprocess_split
  File "C:\Users\User\Desktop\sovits\venv\lib\site-packages\so_vits_svc_fork\preprocess_split.py", line 45, in <module>
    input_dir: Path | str,
TypeError: unsupported operand type(s) for |: 'type' and 'type'
```
-h should be -ho or -hop
Need to add from __futures

Resolving patch:
diff --git a/src/so_vits_svc_fork/__main__.py b/src/so_vits_svc_fork/__main__.py
--- a/src/so_vits_svc_fork/__main__.py
+++ b/src/so_vits_svc_fork/__main__.py
@@ -438,7 +438,9 @@ def vc(
 )
 @click.option("-d", "--top-db", type=float, default=30, help="top db")
 @click.option("-f", "--frame-seconds", type=float, default=1, help="frame seconds")
-@click.option("-h", "--hop-seconds", type=float, default=0.3, help="hop seconds")
+@click.option(
+    "-ho", "-hop", "--hop-seconds", type=float, default=0.3, help="hop seconds"
+)
 def pre_resample(
     input_dir: Path,
     output_dir: Path,
@@ -653,7 +655,9 @@ def pre_sd(
 )
 @click.option("-d", "--top-db", type=float, default=30, help="top db")
 @click.option("-f", "--frame-seconds", type=float, default=1, help="frame seconds")
-@click.option("-h", "--hop-seconds", type=float, default=0.3, help="hop seconds")
+@click.option(
+    "-ho", "-hop", "--hop-seconds", type=float, default=0.3, help="hop seconds"
+)
 @click.option("-s", "--sr", type=int, default=44100, help="sample rate")
 def pre_split(
     input_dir: Path | str,
diff --git a/src/so_vits_svc_fork/preprocess_speaker_diarization.py b/src/so_vits_svc_fork/preprocess_speaker_diarization.py
--- a/src/so_vits_svc_fork/preprocess_speaker_diarization.py
+++ b/src/so_vits_svc_fork/preprocess_speaker_diarization.py
@@ -1,3 +1,5 @@
+from __future__ import annotations
+
 from collections import defaultdict
 from logging import getLogger
 from pathlib import Path
diff --git a/src/so_vits_svc_fork/preprocess_split.py b/src/so_vits_svc_fork/preprocess_split.py
--- a/src/so_vits_svc_fork/preprocess_split.py
+++ b/src/so_vits_svc_fork/preprocess_split.py
@@ -1,8 +1,9 @@
+from __future__ import annotations
+
 from logging import getLogger
 from pathlib import Path
 
 import librosa
-import soundfile
 import soundfile as sf
 from joblib import Parallel, delayed
 from tqdm import tqdm


Test patch:
diff --git a/tests/test_main.py b/tests/test_main.py
--- a/tests/test_main.py
+++ b/tests/test_main.py
@@ -15,6 +15,7 @@ def test_import(self):
         import so_vits_svc_fork.preprocess_flist_config  # noqa
         import so_vits_svc_fork.preprocess_hubert_f0  # noqa
         import so_vits_svc_fork.preprocess_resample  # noqa
+        import so_vits_svc_fork.preprocess_split  # noqa
         import so_vits_svc_fork.train  # noqa
 
     def test_infer(self):