From fc08b62d05723cdc1ce021bb8ba044ca014fb1f7 Mon Sep 17 00:00:00 2001
From: 游雁 <zhifu.gzf@alibaba-inc.com>
Date: 星期一, 13 三月 2023 18:38:41 +0800
Subject: [PATCH] readme
---
funasr/utils/wav_utils.py | 16 +++++++++++-----
1 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/funasr/utils/wav_utils.py b/funasr/utils/wav_utils.py
index afc0ec9..4a764a9 100644
--- a/funasr/utils/wav_utils.py
+++ b/funasr/utils/wav_utils.py
@@ -298,18 +298,24 @@
os.rename(text_file, "{}.bak".format(text_file))
wav_dict = {}
for line in wav_lines:
- sample_name, wav_path = line.strip().split()
+ parts = line.strip().split()
+ if len(parts) < 2:
+ continue
+ sample_name, wav_path = parts
wav_dict[sample_name] = wav_path
text_dict = {}
for line in text_lines:
- sample_name, txt = line.strip().split(" ", 1)
- text_dict[sample_name] = txt
+ parts = line.strip().split()
+ if len(parts) < 2:
+ continue
+ sample_name = parts[0]
+ text_dict[sample_name] = " ".join(parts[1:]).lower()
filter_count = 0
- with open(wav_file) as f_wav, open(text_file) as f_text:
+ with open(wav_file, "w") as f_wav, open(text_file, "w") as f_text:
for sample_name, wav_path in wav_dict.items():
if sample_name in text_dict.keys():
f_wav.write(sample_name + " " + wav_path + "\n")
f_text.write(sample_name + " " + text_dict[sample_name] + "\n")
else:
filter_count += 1
- print("{}/{} samples in {} are filtered because of the mismatch between wav.scp and text".format(len(wav_lines), filter_count, dataset))
\ No newline at end of file
+ print("{}/{} samples in {} are filtered because of the mismatch between wav.scp and text".format(len(wav_lines), filter_count, dataset))
--
Gitblit v1.9.1