Skip to content

SOTA Open Source TTS

Improve file list and vq performance (#131)

Stardust·减4b335e218e43
diff --git a/fish_speech/utils/file.py b/fish_speech/utils/file.py
index f5e7d1c..0517b99 100644
--- a/fish_speech/utils/file.py
+++ b/fish_speech/utils/file.py
@@ -44,10 +44,11 @@ def list_files(
if not path.exists():
raise FileNotFoundError(f"Directory {path} does not exist.")
- files = [Path(f) for f in glob(str(path / "**/*"), recursive=recursive)]
+ # files = [Path(f) for f in glob(str(path / "**/*"), recursive=recursive)]
+ files = [file for ext in extensions for file in directory.glob(f"**/*{ext}")]
- if extensions is not None:
- files = [f for f in files if f.suffix in extensions]
+ # if extensions is not None:
+ # files = [f for f in files if f.suffix in extensions]
if sort:
files = natsorted(files)
diff --git a/tools/vqgan/extract_vq.py b/tools/vqgan/extract_vq.py
index f6a3c9d..c8771fa 100644
--- a/tools/vqgan/extract_vq.py
+++ b/tools/vqgan/extract_vq.py
@@ -41,7 +41,7 @@ logger.add(sys.stderr, format=logger_format)
@lru_cache(maxsize=1)
def get_model(
- config_name: str = "vqgan",
+ config_name: str = "vqgan_pretrain",
checkpoint_path: str = "checkpoints/vqgan/step_000380000.ckpt",
):
with initialize(version_base="1.3", config_path="../../fish_speech/configs"):
@@ -72,7 +72,9 @@ def process_batch(files: list[Path], model) -> float:
for file in files:
try:
- wav, sr = torchaudio.load(file)
+ wav, sr = torchaudio.load(
+ str(file), backend="sox"
+ ) # Need to install libsox-dev
except Exception as e:
logger.error(f"Error reading {file}: {e}")
continue
@@ -169,11 +171,10 @@ def main(
if filelist:
files = [i[0] for i in load_filelist(filelist)]
else:
- files = list_files(folder, AUDIO_EXTENSIONS, recursive=True, sort=True)
+ files = list_files(folder, AUDIO_EXTENSIONS, recursive=True, sort=False)
print(f"Found {len(files)} files")
- files = [Path(f) for f in files if not Path(f).with_suffix(".npy").exists()]
- Random(42).shuffle(files)
+ # files = [Path(f) for f in files if not Path(f).with_suffix(".npy").exists()]
total_files = len(files)
files = files[RANK::WORLD_SIZE]