File size: 646 Bytes
f450982
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from typing import List
import argparse
import torch
from speechbrain.pretrained import EncoderDecoderASR


def asr_model_inference(asr_model: EncoderDecoderASR, audios: List[str]) -> List[str]:
    return [asr_model.transcribe_file(audio) for audio in audios]


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("-I", dest="audio_file", required=True)

    args = parser.parse_args()

    asr_model = EncoderDecoderASR.from_hparams(
        source="./infernce", hparams_file="hyperparams.yaml", savedir="inference", run_opts={"device": "cpu"})

    print(asr_model_inference(asr_model, [args.audio_file]))