Skip to content

Commit 2ac522f

Browse files
authored
Merge pull request #2117 from HuanLinOTO/feat-fallback-encoding
feat: fallback to system encoding when fail to read file with utf-8
2 parents 64b78be + f0dd73a commit 2ac522f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

infer/lib/train/utils.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,13 @@ def load_wav_to_torch(full_path):
278278

279279

280280
def load_filepaths_and_text(filename, split="|"):
281-
with open(filename, encoding="utf-8") as f:
282-
filepaths_and_text = [line.strip().split(split) for line in f]
281+
try:
282+
with open(filename, encoding="utf-8") as f:
283+
filepaths_and_text = [line.strip().split(split) for line in f]
284+
except UnicodeDecodeError:
285+
with open(filename) as f:
286+
filepaths_and_text = [line.strip().split(split) for line in f]
287+
283288
return filepaths_and_text
284289

285290

0 commit comments

Comments
 (0)