Fix two bugs for blank voice (empty speech): (#1403)

First, raw text would always be present whatever param return_raw_text specified.
Second, empty text from punc model would cause error during sentence assembly if sentence_timestamp specified true.
This commit is contained in:
jianganghan 2024-02-29 09:35:34 +08:00 committed by GitHub
parent b9cfd9953a
commit f272eb4ef7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -392,6 +392,7 @@ class AutoModel:
# step.3 compute punc model
if self.punc_model is not None:
if not len(result["text"]):
if return_raw_text:
result['raw_text'] = ''
else:
self.punc_kwargs.update(cfg)
@ -434,6 +435,9 @@ class AutoModel:
distribute_spk(sentence_list, sv_output)
result['sentence_info'] = sentence_list
elif kwargs.get("sentence_timestamp", False):
if not len(result['text']):
sentence_list = []
else:
sentence_list = timestamp_sentence(punc_res[0]['punc_array'],
result['timestamp'],
raw_text,