Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions fish_vocoder/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def main(cfg: DictConfig):
audios = list(input_path.rglob("*"))

for audio_path in audios:
if audio_path.suffix in [".wav", ".flac", ".mp3"]:
suffix = audio_path.suffix.lower()
if suffix in [".wav", ".flac", ".mp3"]:
gt_y, sr = librosa.load(audio_path, sr=cfg.model.sampling_rate, mono=False)

# If mono, add a channel dimension
Expand All @@ -70,7 +71,7 @@ def main(cfg: DictConfig):
logger.info(f"gt_y shape: {gt_y.shape}, lengths: {lengths}")
inputs = model.mel_transforms.input(gt_y.squeeze(1))

elif audio_path.suffix in [".pt", ".pth"]:
elif suffix in [".pt", ".pth"]:
input_mels = torch.load(audio_path, map_location=model.device).to(
torch.float32
)
Expand Down
6 changes: 5 additions & 1 deletion fish_vocoder/utils/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ def list_files(
)

if extensions is not None:
files = [f for f in files if f.suffix in extensions]
# Match case-insensitively. Recorders, phones and camera firmware write
# .WAV/.MP3, and Path.suffix preserves that case, so an exact match
# dropped those files from the dataset without a warning.
extensions = {ext.lower() for ext in extensions}
files = [f for f in files if f.suffix.lower() in extensions]

if sort:
files = sorted(files)
Expand Down
6 changes: 5 additions & 1 deletion scripts/random_copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ def random_copy(src: Path, dst: Path, num: int, seed: int):

src, dst = Path(src), Path(dst)

files = [f for f in src.rglob("*") if f.is_file() and f.suffix in [".wav", ".flac"]]
files = [
f
for f in src.rglob("*")
if f.is_file() and f.suffix.lower() in [".wav", ".flac"]
]
logger.info(f"Found {len(files)} files in {src}")

generator = random.Random(seed)
Expand Down