1
0
mirror of https://github.com/fumiama/Retrieval-based-Voice-Conversion-WebUI.git synced 2026-06-07 02:00:25 +08:00

perf: improve codec handling in load_filepaths_and_text function in infer.lib.train.utils (#44)

This commit is contained in:
Alex Murkoff
2024-06-12 19:53:56 +07:00
committed by GitHub
parent 26d17cd714
commit 09285d5f5b

View File

@@ -5,6 +5,7 @@ import logging
import os import os
import sys import sys
import codecs
import numpy as np import numpy as np
import torch import torch
from scipy.io.wavfile import read from scipy.io.wavfile import read
@@ -251,13 +252,11 @@ def load_wav_to_torch(full_path):
def load_filepaths_and_text(filename, split="|"): def load_filepaths_and_text(filename, split="|"):
try: try:
with open(filename, encoding="utf-8") as f: return [line.strip().split(split) for line in codecs.open(filename, encoding="utf-8")]
filepaths_and_text = [line.strip().split(split) for line in f] except UnicodeDecodeError as e:
except UnicodeDecodeError: logger.error("Error loading file %s: %s", filename, e)
with open(filename) as f:
filepaths_and_text = [line.strip().split(split) for line in f]
return filepaths_and_text return []
def get_hparams(init=True): def get_hparams(init=True):