(args)
| 37 | |
| 38 | |
| 39 | def main(args): |
| 40 | wavs = get_wav_info(args) |
| 41 | fout = open(args.output, "w") if args.output else None |
| 42 | |
| 43 | model = FireRedAsr.from_pretrained(args.asr_type, args.model_dir) |
| 44 | |
| 45 | batch_uttid = [] |
| 46 | batch_wav_path = [] |
| 47 | for i, wav in enumerate(wavs): |
| 48 | uttid, wav_path = wav |
| 49 | batch_uttid.append(uttid) |
| 50 | batch_wav_path.append(wav_path) |
| 51 | if len(batch_wav_path) < args.batch_size and i != len(wavs) - 1: |
| 52 | continue |
| 53 | |
| 54 | results = model.transcribe( |
| 55 | batch_uttid, |
| 56 | batch_wav_path, |
| 57 | { |
| 58 | "use_gpu": args.use_gpu, |
| 59 | "beam_size": args.beam_size, |
| 60 | "nbest": args.nbest, |
| 61 | "decode_max_len": args.decode_max_len, |
| 62 | "softmax_smoothing": args.softmax_smoothing, |
| 63 | "aed_length_penalty": args.aed_length_penalty, |
| 64 | "eos_penalty": args.eos_penalty, |
| 65 | "decode_min_len": args.decode_min_len, |
| 66 | "repetition_penalty": args.repetition_penalty, |
| 67 | "llm_length_penalty": args.llm_length_penalty, |
| 68 | "temperature": args.temperature |
| 69 | } |
| 70 | ) |
| 71 | |
| 72 | for result in results: |
| 73 | print(result) |
| 74 | if fout is not None: |
| 75 | fout.write(f"{result['uttid']}\t{result['text']}\n") |
| 76 | |
| 77 | batch_uttid = [] |
| 78 | batch_wav_path = [] |
| 79 | |
| 80 | |
| 81 | def get_wav_info(args): |
no test coverage detected