We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Ensure proper sorting by name for output files
### Is your feature request related to a problem? Please describe.

To enhance readability and ensure proper sorting by name, the numeric part of output file names should have a fixed width. This can be achieved by adding leading zeros to the numeric part, with four digits likely being sufficient.

### Describe alternatives you've considered

I don't have any.

### Additional context

_No response_

### Code of Conduct

- [X] I agree to follow this project's Code of Conduct

### Are you willing to resolve this issue by submitting a Pull Request?

- [X] Yes, I have the time, and I know how to start.
- [ ] Yes, I have the time, but I don't know how to start. I would need guidance.
- [ ] No, I don't have the time, although I believe I could do it if I had the time...
- [ ] No, I don't have the time and I wouldn't even know how to start.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `src/so_vits_svc_fork/preprocessing/preprocess_speaker_diarization.py`
Content:
```
1 from __future__ import annotations
2 
3 from collections import defaultdict
4 from logging import getLogger
5 from pathlib import Path
6 
7 import librosa
8 import soundfile as sf
9 import torch
10 from joblib import Parallel, delayed
11 from pyannote.audio import Pipeline
12 from tqdm import tqdm
13 from tqdm_joblib import tqdm_joblib
14 
15 LOG = getLogger(__name__)
16 
17 
18 def _process_one(
19     input_path: Path,
20     output_dir: Path,
21     sr: int,
22     *,
23     min_speakers: int = 1,
24     max_speakers: int = 1,
25     huggingface_token: str | None = None,
26 ) -> None:
27     try:
28         audio, sr = librosa.load(input_path, sr=sr, mono=True)
29     except Exception as e:
30         LOG.warning(f"Failed to read {input_path}: {e}")
31         return
32     pipeline = Pipeline.from_pretrained(
33         "pyannote/speaker-diarization", use_auth_token=huggingface_token
34     )
35     if pipeline is None:
36         raise ValueError("Failed to load pipeline")
37     pipeline = pipeline.to(torch.device("cuda"))
38     LOG.info(f"Processing {input_path}. This may take a while...")
39     diarization = pipeline(
40         input_path, min_speakers=min_speakers, max_speakers=max_speakers
41     )
42 
43     LOG.info(f"Found {len(diarization)} tracks, writing to {output_dir}")
44     speaker_count = defaultdict(int)
45 
46     output_dir.mkdir(parents=True, exist_ok=True)
47     for segment, track, speaker in tqdm(
48         list(diarization.itertracks(yield_label=True)), desc=f"Writing {input_path}"
49     ):
50         if segment.end - segment.start < 1:
51             continue
52         speaker_count[speaker] += 1
53         audio_cut = audio[int(segment.start * sr) : int(segment.end * sr)]
54         sf.write(
55             (output_dir / f"{speaker}_{speaker_count[speaker]}.wav"),
56             audio_cut,
57             sr,
58         )
59 
60     LOG.info(f"Speaker count: {speaker_count}")
61 
62 
63 def preprocess_speaker_diarization(
64     input_dir: Path | str,
65     output_dir: Path | str,
66     sr: int,
67     *,
68     min_speakers: int = 1,
69     max_speakers: int = 1,
70     huggingface_token: str | None = None,
71     n_jobs: int = -1,
72 ) -> None:
73     if huggingface_token is not None and not huggingface_token.startswith("hf_"):
74         LOG.warning("Huggingface token probably should start with hf_")
75     if not torch.cuda.is_available():
76         LOG.warning("CUDA is not available. This will be extremely slow.")
77     input_dir = Path(input_dir)
78     output_dir = Path(output_dir)
79     input_dir.mkdir(parents=True, exist_ok=True)
80     output_dir.mkdir(parents=True, exist_ok=True)
81     input_paths = list(input_dir.rglob("*.*"))
82     with tqdm_joblib(desc="Preprocessing speaker diarization", total=len(input_paths)):
83         Parallel(n_jobs=n_jobs)(
84             delayed(_process_one)(
85                 input_path,
86                 output_dir / input_path.relative_to(input_dir).parent / input_path.stem,
87                 sr,
88                 max_speakers=max_speakers,
89                 min_speakers=min_speakers,
90                 huggingface_token=huggingface_token,
91             )
92             for input_path in input_paths
93         )
94
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/src/so_vits_svc_fork/preprocessing/preprocess_speaker_diarization.py b/src/so_vits_svc_fork/preprocessing/preprocess_speaker_diarization.py
--- a/src/so_vits_svc_fork/preprocessing/preprocess_speaker_diarization.py
+++ b/src/so_vits_svc_fork/preprocessing/preprocess_speaker_diarization.py
@@ -52,7 +52,7 @@
         speaker_count[speaker] += 1
         audio_cut = audio[int(segment.start * sr) : int(segment.end * sr)]
         sf.write(
-            (output_dir / f"{speaker}_{speaker_count[speaker]}.wav"),
+            (output_dir / f"{speaker}_{speaker_count[speaker]:04d}.wav"),
             audio_cut,
             sr,
         )

{"golden_diff": "diff --git a/src/so_vits_svc_fork/preprocessing/preprocess_speaker_diarization.py b/src/so_vits_svc_fork/preprocessing/preprocess_speaker_diarization.py\n--- a/src/so_vits_svc_fork/preprocessing/preprocess_speaker_diarization.py\n+++ b/src/so_vits_svc_fork/preprocessing/preprocess_speaker_diarization.py\n@@ -52,7 +52,7 @@\n         speaker_count[speaker] += 1\n         audio_cut = audio[int(segment.start * sr) : int(segment.end * sr)]\n         sf.write(\n-            (output_dir / f\"{speaker}_{speaker_count[speaker]}.wav\"),\n+            (output_dir / f\"{speaker}_{speaker_count[speaker]:04d}.wav\"),\n             audio_cut,\n             sr,\n         )\n", "issue": "Ensure proper sorting by name for output files\n### Is your feature request related to a problem? Please describe.\n\nTo enhance readability and ensure proper sorting by name, the numeric part of output file names should have a fixed width. This can be achieved by adding leading zeros to the numeric part, with four digits likely being sufficient.\n\n### Describe alternatives you've considered\n\nI don't have any.\n\n### Additional context\n\n_No response_\n\n### Code of Conduct\n\n- [X] I agree to follow this project's Code of Conduct\n\n### Are you willing to resolve this issue by submitting a Pull Request?\n\n- [X] Yes, I have the time, and I know how to start.\n- [ ] Yes, I have the time, but I don't know how to start. I would need guidance.\n- [ ] No, I don't have the time, although I believe I could do it if I had the time...\n- [ ] No, I don't have the time and I wouldn't even know how to start.\n", "before_files": [{"content": "from __future__ import annotations\n\nfrom collections import defaultdict\nfrom logging import getLogger\nfrom pathlib import Path\n\nimport librosa\nimport soundfile as sf\nimport torch\nfrom joblib import Parallel, delayed\nfrom pyannote.audio import Pipeline\nfrom tqdm import tqdm\nfrom tqdm_joblib import tqdm_joblib\n\nLOG = getLogger(__name__)\n\n\ndef _process_one(\n    input_path: Path,\n    output_dir: Path,\n    sr: int,\n    *,\n    min_speakers: int = 1,\n    max_speakers: int = 1,\n    huggingface_token: str | None = None,\n) -> None:\n    try:\n        audio, sr = librosa.load(input_path, sr=sr, mono=True)\n    except Exception as e:\n        LOG.warning(f\"Failed to read {input_path}: {e}\")\n        return\n    pipeline = Pipeline.from_pretrained(\n        \"pyannote/speaker-diarization\", use_auth_token=huggingface_token\n    )\n    if pipeline is None:\n        raise ValueError(\"Failed to load pipeline\")\n    pipeline = pipeline.to(torch.device(\"cuda\"))\n    LOG.info(f\"Processing {input_path}. This may take a while...\")\n    diarization = pipeline(\n        input_path, min_speakers=min_speakers, max_speakers=max_speakers\n    )\n\n    LOG.info(f\"Found {len(diarization)} tracks, writing to {output_dir}\")\n    speaker_count = defaultdict(int)\n\n    output_dir.mkdir(parents=True, exist_ok=True)\n    for segment, track, speaker in tqdm(\n        list(diarization.itertracks(yield_label=True)), desc=f\"Writing {input_path}\"\n    ):\n        if segment.end - segment.start < 1:\n            continue\n        speaker_count[speaker] += 1\n        audio_cut = audio[int(segment.start * sr) : int(segment.end * sr)]\n        sf.write(\n            (output_dir / f\"{speaker}_{speaker_count[speaker]}.wav\"),\n            audio_cut,\n            sr,\n        )\n\n    LOG.info(f\"Speaker count: {speaker_count}\")\n\n\ndef preprocess_speaker_diarization(\n    input_dir: Path | str,\n    output_dir: Path | str,\n    sr: int,\n    *,\n    min_speakers: int = 1,\n    max_speakers: int = 1,\n    huggingface_token: str | None = None,\n    n_jobs: int = -1,\n) -> None:\n    if huggingface_token is not None and not huggingface_token.startswith(\"hf_\"):\n        LOG.warning(\"Huggingface token probably should start with hf_\")\n    if not torch.cuda.is_available():\n        LOG.warning(\"CUDA is not available. This will be extremely slow.\")\n    input_dir = Path(input_dir)\n    output_dir = Path(output_dir)\n    input_dir.mkdir(parents=True, exist_ok=True)\n    output_dir.mkdir(parents=True, exist_ok=True)\n    input_paths = list(input_dir.rglob(\"*.*\"))\n    with tqdm_joblib(desc=\"Preprocessing speaker diarization\", total=len(input_paths)):\n        Parallel(n_jobs=n_jobs)(\n            delayed(_process_one)(\n                input_path,\n                output_dir / input_path.relative_to(input_dir).parent / input_path.stem,\n                sr,\n                max_speakers=max_speakers,\n                min_speakers=min_speakers,\n                huggingface_token=huggingface_token,\n            )\n            for input_path in input_paths\n        )\n", "path": "src/so_vits_svc_fork/preprocessing/preprocess_speaker_diarization.py"}], "after_files": [{"content": "from __future__ import annotations\n\nfrom collections import defaultdict\nfrom logging import getLogger\nfrom pathlib import Path\n\nimport librosa\nimport soundfile as sf\nimport torch\nfrom joblib import Parallel, delayed\nfrom pyannote.audio import Pipeline\nfrom tqdm import tqdm\nfrom tqdm_joblib import tqdm_joblib\n\nLOG = getLogger(__name__)\n\n\ndef _process_one(\n    input_path: Path,\n    output_dir: Path,\n    sr: int,\n    *,\n    min_speakers: int = 1,\n    max_speakers: int = 1,\n    huggingface_token: str | None = None,\n) -> None:\n    try:\n        audio, sr = librosa.load(input_path, sr=sr, mono=True)\n    except Exception as e:\n        LOG.warning(f\"Failed to read {input_path}: {e}\")\n        return\n    pipeline = Pipeline.from_pretrained(\n        \"pyannote/speaker-diarization\", use_auth_token=huggingface_token\n    )\n    if pipeline is None:\n        raise ValueError(\"Failed to load pipeline\")\n    pipeline = pipeline.to(torch.device(\"cuda\"))\n    LOG.info(f\"Processing {input_path}. This may take a while...\")\n    diarization = pipeline(\n        input_path, min_speakers=min_speakers, max_speakers=max_speakers\n    )\n\n    LOG.info(f\"Found {len(diarization)} tracks, writing to {output_dir}\")\n    speaker_count = defaultdict(int)\n\n    output_dir.mkdir(parents=True, exist_ok=True)\n    for segment, track, speaker in tqdm(\n        list(diarization.itertracks(yield_label=True)), desc=f\"Writing {input_path}\"\n    ):\n        if segment.end - segment.start < 1:\n            continue\n        speaker_count[speaker] += 1\n        audio_cut = audio[int(segment.start * sr) : int(segment.end * sr)]\n        sf.write(\n            (output_dir / f\"{speaker}_{speaker_count[speaker]:04d}.wav\"),\n            audio_cut,\n            sr,\n        )\n\n    LOG.info(f\"Speaker count: {speaker_count}\")\n\n\ndef preprocess_speaker_diarization(\n    input_dir: Path | str,\n    output_dir: Path | str,\n    sr: int,\n    *,\n    min_speakers: int = 1,\n    max_speakers: int = 1,\n    huggingface_token: str | None = None,\n    n_jobs: int = -1,\n) -> None:\n    if huggingface_token is not None and not huggingface_token.startswith(\"hf_\"):\n        LOG.warning(\"Huggingface token probably should start with hf_\")\n    if not torch.cuda.is_available():\n        LOG.warning(\"CUDA is not available. This will be extremely slow.\")\n    input_dir = Path(input_dir)\n    output_dir = Path(output_dir)\n    input_dir.mkdir(parents=True, exist_ok=True)\n    output_dir.mkdir(parents=True, exist_ok=True)\n    input_paths = list(input_dir.rglob(\"*.*\"))\n    with tqdm_joblib(desc=\"Preprocessing speaker diarization\", total=len(input_paths)):\n        Parallel(n_jobs=n_jobs)(\n            delayed(_process_one)(\n                input_path,\n                output_dir / input_path.relative_to(input_dir).parent / input_path.stem,\n                sr,\n                max_speakers=max_speakers,\n                min_speakers=min_speakers,\n                huggingface_token=huggingface_token,\n            )\n            for input_path in input_paths\n        )\n", "path": "src/so_vits_svc_fork/preprocessing/preprocess_speaker_diarization.py"}]}