| | |
| | | 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 |
| | |
| | | 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() |
| | | |
| | |
| | | results_sorted = [] |
| | | |
| | | if not len(sorted_data): |
| | | results_ret_list.append({"key": key, "text": "", "timestamp": []}) |
| | | logging.info("decoding, utt: {}, empty speech".format(key)) |
| | | continue |
| | | |
| | |
| | | ): |
| | | max_len_in_batch = max(max_len_in_batch, sample_length) |
| | | end_idx += 1 |
| | | results_sorted.append({'key': 'bad_data', 'text': '', 'timestamp': []}) |
| | | continue |
| | | |
| | | speech_j, speech_lengths_j = slice_padding_audio_samples( |
| | |
| | | end_idx += 1 |
| | | max_len_in_batch = sample_length |
| | | if len(results) < 1: |
| | | continue |
| | | results.append({'key': 'bad_data', 'text': '', 'timestamp': []}) |
| | | results_sorted.extend(results) |
| | | |
| | | # end_asr_total = time.time() |