Skip to content

SOTA Open Source TTS

fix: honor the `recursive` parameter in list_files() (#1317)

Yuvraj Singh3a5d603cd2be
diff --git a/fish_speech/utils/file.py b/fish_speech/utils/file.py
index a54c226..94da983 100644
--- a/fish_speech/utils/file.py
+++ b/fish_speech/utils/file.py
@@ -78,7 +78,8 @@ def list_files(
if not path.exists():
raise FileNotFoundError(f"Directory {path} does not exist.")
- files = [file for ext in extensions for file in path.rglob(f"*{ext}")]
+ globber = path.rglob if recursive else path.glob
+ files = [file for ext in extensions for file in globber(f"*{ext}")]
if sort:
files = natsorted(files)