Repository: voicepaw/so-vits-svc-fork

Issue:
Pre-resample not running?
Trying to run `svc pre-resample` but it doesn't start:

`(venv) C:\Users\LXC PC\Desktop\sovits\venv\Scripts>svc pre-resample`
`Preprocessing: 0it [00:00, ?it/s]`


Discussion:
https://github.com/34j/so-vits-svc-fork/blob/main/src/so_vits_svc_fork/__main__.py#L374-L374


This part contradicts the documentation...
I managed to get it working by manually specifying the path: `svc pre-resample -i "C:\Users\LXC PC\Desktop\sovits\venv\Scripts\dataset_raw\44k\21Raw"`

Ran through `svc pre-config` and `svc pre-hubert` with no problems.

However, when running `svc train`, I get an error. Here is the stack trace:

```
(venv) C:\Users\LXC PC\Desktop\sovits\venv\Scripts>svc train
'emb_g.weight'
Traceback (most recent call last):
  File "C:\Users\LXC PC\Desktop\sovits\venv\lib\site-packages\so_vits_svc_fork\utils.py", line 385, in load_checkpoint
    new_state_dict[k] = saved_state_dict[k]
KeyError: 'emb_g.weight'
emb_g.weight is not in the checkpoint
  0%|                                                                                        | 0/10000 [00:00<?, ?it/s]C:\Users\LXC PC\Desktop\sovits\venv\lib\site-packages\torch\functional.py:641: UserWarning: stft with return_complex=False is deprecated. In a future pytorch release, stft will return complex tensors for all inputs, and return_complex=False will raise an error.
Note: you can still call torch.view_as_real on the complex output to recover the old return format. (Triggered internally at C:\actions-runner\_work\pytorch\pytorch\builder\windows\pytorch\aten\src\ATen\native\SpectralOps.cpp:867.)
  return _VF.stft(input, n_fft, hop_length, win_length, window,  # type: ignore[attr-defined]
C:\Users\LXC PC\Desktop\sovits\venv\lib\site-packages\torch\autograd\__init__.py:200: UserWarning: Grad strides do not match bucket view strides. This may indicate grad was not created according to the gradient layout contract, or that the param's strides changed since DDP was constructed.  This is not an error, but may impair performance.
grad.sizes() = [32, 1, 4], strides() = [4, 1, 1]
bucket_view.sizes() = [32, 1, 4], strides() = [4, 4, 1] (Triggered internally at C:\actions-runner\_work\pytorch\pytorch\builder\windows\pytorch\torch\csrc\distributed\c10d\reducer.cpp:337.)
  Variable._execution_engine.run_backward(  # Calls into the C++ engine to run the backward pass
  0%|                                                                                        | 0/10000 [00:13<?, ?it/s]
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 119, in train
    train(config_path=config_path, model_path=model_path)
  File "C:\Users\LXC PC\Desktop\sovits\venv\lib\site-packages\so_vits_svc_fork\train.py", line 49, in train
    mp.spawn(
  File "C:\Users\LXC PC\Desktop\sovits\venv\lib\site-packages\torch\multiprocessing\spawn.py", line 239, in spawn
    return start_processes(fn, args, nprocs, join, daemon, start_method='spawn')
  File "C:\Users\LXC PC\Desktop\sovits\venv\lib\site-packages\torch\multiprocessing\spawn.py", line 197, in start_processes
    while not context.join():
  File "C:\Users\LXC PC\Desktop\sovits\venv\lib\site-packages\torch\multiprocessing\spawn.py", line 160, in join
    raise ProcessRaisedException(msg, error_index, failed_process.pid)
torch.multiprocessing.spawn.ProcessRaisedException:

-- Process 0 terminated with the following error:
Traceback (most recent call last):
  File "C:\Users\LXC PC\Desktop\sovits\venv\lib\site-packages\torch\multiprocessing\spawn.py", line 69, in _wrap
    fn(i, *args)
  File "C:\Users\LXC PC\Desktop\sovits\venv\lib\site-packages\so_vits_svc_fork\train.py", line 158, in run
    train_and_evaluate(
  File "C:\Users\LXC PC\Desktop\sovits\venv\lib\site-packages\so_vits_svc_fork\train.py", line 338, in train_and_evaluate
    evaluate(hps, net_g, eval_loader, writer_eval)
  File "C:\Users\LXC PC\Desktop\sovits\venv\lib\site-packages\so_vits_svc_fork\train.py", line 376, in evaluate
    for batch_idx, items in enumerate(eval_loader):
  File "C:\Users\LXC PC\Desktop\sovits\venv\lib\site-packages\torch\utils\data\dataloader.py", line 634, in __next__
    data = self._next_data()
  File "C:\Users\LXC PC\Desktop\sovits\venv\lib\site-packages\torch\utils\data\dataloader.py", line 1346, in _next_data
    return self._process_data(data)
  File "C:\Users\LXC PC\Desktop\sovits\venv\lib\site-packages\torch\utils\data\dataloader.py", line 1372, in _process_data
    data.reraise()
  File "C:\Users\LXC PC\Desktop\sovits\venv\lib\site-packages\torch\_utils.py", line 644, in reraise
    raise exception
AssertionError: Caught AssertionError in DataLoader worker process 0.
Original Traceback (most recent call last):
  File "C:\Users\LXC PC\Desktop\sovits\venv\lib\site-packages\torch\utils\data\_utils\worker.py", line 308, in _worker_loop
    data = fetcher.fetch(index)
  File "C:\Users\LXC PC\Desktop\sovits\venv\lib\site-packages\torch\utils\data\_utils\fetch.py", line 51, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "C:\Users\LXC PC\Desktop\sovits\venv\lib\site-packages\torch\utils\data\_utils\fetch.py", line 51, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "C:\Users\LXC PC\Desktop\sovits\venv\lib\site-packages\so_vits_svc_fork\data_utils.py", line 104, in __getitem__
    return self.get_audio(self.audiopaths[index][0])
  File "C:\Users\LXC PC\Desktop\sovits\venv\lib\site-packages\so_vits_svc_fork\data_utils.py", line 78, in get_audio
    assert abs(c.size(-1) - spec.size(-1)) < 3, (
AssertionError: (1398, 1392, torch.Size([1398]), 'dataset/44k/21Raw/101.wav')
```
Was the logs/44k empty from the beginning?
logs/44k contains these files:

![01](https://user-images.githubusercontent.com/125531852/226294228-4d5cbd10-f778-4b09-b12c-1d6d1a29ab28.png)

Was it empty at first?
You mean before doing `svc train`? I think so, yea. It only created the `logs` folder after running the command. The folder didnt exist before then.
This is due to the fact that I migrated the library for f0 inference from dio to crepe without adequate testing. Please use version <0.8.0. Sorry for your inconvenience.

Resolving patch:
diff --git a/src/so_vits_svc_fork/utils.py b/src/so_vits_svc_fork/utils.py
--- a/src/so_vits_svc_fork/utils.py
+++ b/src/so_vits_svc_fork/utils.py
@@ -13,7 +13,7 @@
 import torchcrepe
 from numpy import dtype, float32, ndarray
 from scipy.io.wavfile import read
-from torch import FloatTensor
+from torch import FloatTensor, Tensor
 from tqdm import tqdm
 
 LOG = getLogger(__name__)
@@ -219,7 +219,7 @@ def compute_f0_crepe(
     # (T) -> (1, T)
     audio = audio.detach()
 
-    pitch = torchcrepe.predict(
+    pitch: Tensor = torchcrepe.predict(
         audio,
         sampling_rate,
         hop_length,
@@ -231,7 +231,10 @@ def compute_f0_crepe(
         pad=True,
     )
 
-    return pitch.detach().cpu().numpy()[0]
+    f0 = pitch.squeeze(0).cpu().numpy()
+    p_len = p_len or wav_numpy.shape[0] // hop_length
+    f0 = _resize_f0(f0, p_len)
+    return f0
 
 
 def compute_f0(


Test patch: