Skip to content

SOTA Open Source TTS

Switch to glob for faster dataset split (#24)

OedoSoldier99150ba4def7
diff --git a/fish_speech/utils/file.py b/fish_speech/utils/file.py
index 1c20a13..7838f38 100644
--- a/fish_speech/utils/file.py
+++ b/fish_speech/utils/file.py
@@ -1,4 +1,5 @@
import os
+from glob import glob
from pathlib import Path
from typing import Union
@@ -42,16 +43,7 @@ def list_files(
if not path.exists():
raise FileNotFoundError(f"Directory {path} does not exist.")
- files = (
- [
- Path(os.path.join(root, filename))
- for root, _, filenames in os.walk(path, followlinks=True)
- for filename in filenames
- if Path(os.path.join(root, filename)).is_file()
- ]
- if recursive
- else [f for f in path.glob("*") if f.is_file()]
- )
+ files = [Path(f) for f in glob(str(path / "**/*"), recursive=recursive)]
if extensions is not None:
files = [f for f in files if f.suffix in extensions]