提交 ed0138c6 编写于 作者: D david.95

add condition check if a ssml input and filter space line, test=tts

上级 21cce0e0
...@@ -105,14 +105,15 @@ def get_sentences(text_file: Optional[os.PathLike], lang: str='zh'): ...@@ -105,14 +105,15 @@ def get_sentences(text_file: Optional[os.PathLike], lang: str='zh'):
sentences = [] sentences = []
with open(text_file, 'rt') as f: with open(text_file, 'rt') as f:
for line in f: for line in f:
items = re.split(r"\s+", line.strip(), 1) if line.strip() != "":
utt_id = items[0] items = re.split(r"\s+", line.strip(), 1)
if lang == 'zh': utt_id = items[0]
sentence = "".join(items[1:]) if lang == 'zh':
elif lang == 'en': sentence = "".join(items[1:])
sentence = " ".join(items[1:]) elif lang == 'en':
elif lang == 'mix': sentence = " ".join(items[1:])
sentence = " ".join(items[1:]) elif lang == 'mix':
sentence = " ".join(items[1:])
sentences.append((utt_id, sentence)) sentences.append((utt_id, sentence))
return sentences return sentences
...@@ -182,11 +183,20 @@ def run_frontend(frontend: object, ...@@ -182,11 +183,20 @@ def run_frontend(frontend: object,
to_tensor: bool=True): to_tensor: bool=True):
outs = dict() outs = dict()
if lang == 'zh': if lang == 'zh':
input_ids = frontend.get_input_ids_ssml( input_ids = {}
text, if text.strip() != "" and re.match(r".*?<speak>.*?</speak>.*", text,
merge_sentences=merge_sentences, re.DOTALL):
get_tone_ids=get_tone_ids, input_ids = frontend.get_input_ids_ssml(
to_tensor=to_tensor) text,
merge_sentences=merge_sentences,
get_tone_ids=get_tone_ids,
to_tensor=to_tensor)
else:
input_ids = frontend.get_input_ids(
text,
merge_sentences=merge_sentences,
get_tone_ids=get_tone_ids,
to_tensor=to_tensor)
phone_ids = input_ids["phone_ids"] phone_ids = input_ids["phone_ids"]
if get_tone_ids: if get_tone_ids:
tone_ids = input_ids["tone_ids"] tone_ids = input_ids["tone_ids"]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册