فهرست منبع

Switch to glob for faster dataset split (#24)

OedoSoldier 2 سال پیش
والد
کامیت
99150ba4de
1فایلهای تغییر یافته به همراه2 افزوده شده و 10 حذف شده
  1. 2 10
      fish_speech/utils/file.py

+ 2 - 10
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]