Skip to content

Commit

Permalink
fix empty asr result (#1765)
Browse files Browse the repository at this point in the history
解码结果为空的语音片段,text 用空字符串
  • Loading branch information
pengzhendong committed May 28, 2024
1 parent 50b2668 commit bd3b180
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions funasr/auto/auto_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ def prepare_data_iterator(data_in, input_len=None, data_type=None, key=None):
filelist = [".scp", ".txt", ".json", ".jsonl", ".text"]

chars = string.ascii_letters + string.digits
if isinstance(data_in, str) and data_in.startswith("http://"): # url
data_in = download_from_url(data_in)
if isinstance(data_in, str):
if data_in.startswith("http://") or data_in.startswith("https://"): # url
data_in = download_from_url(data_in)

if isinstance(data_in, str) and os.path.exists(
data_in
Expand Down Expand Up @@ -284,7 +285,7 @@ def inference(self, input, input_len=None, model=None, kwargs=None, key=None, **
with torch.no_grad():
res = model.inference(**batch, **kwargs)
if isinstance(res, (list, tuple)):
results = res[0]
results = res[0] if len(res) > 0 else [{"text": ""}]
meta_data = res[1] if len(res) > 1 else {}
time2 = time.perf_counter()

Expand Down

0 comments on commit bd3b180

Please sign in to comment.