File size: 789 Bytes
0479abb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import argparse
from typing import Dict

import nemo.collections.asr as nemo_asr


def predict_model(model_path: str, audio_file_path: str) -> Dict:
    # Restore the ASR model from the provided path
    model = nemo_asr.models.ASRModel.restore_from(restore_path=model_path)
    # Transcribe the given audio file
    text = model.transcribe([audio_file_path])
    print({"result": text[0]})


if __name__ == "__main__":
    # Parse command line arguments
    parser = argparse.ArgumentParser()
    parser.add_argument("--model_path", default=None, help="Path to a model to evaluate.")
    parser.add_argument("--audio_file_path", help="Path for train manifest JSON file.")
    args = parser.parse_args()

    predict_model(model_path=args.model_path, audio_file_path=args.audio_file_path)