Skip to content

Commit

Permalink
[MMS] Add a tutorial on CC LM decoding for ASR model (#5160)
Browse files Browse the repository at this point in the history
* Update MMS_ASR_Inference_Colab.ipynb

* Update mms_infer.py
  • Loading branch information
vineelpratap committed May 26, 2023
1 parent 68c52f5 commit 35641fb
Show file tree
Hide file tree
Showing 2 changed files with 1,303 additions and 94 deletions.
3 changes: 2 additions & 1 deletion examples/mms/asr/infer/mms_infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def parser():
parser.add_argument("--audio", type=str, help="path to audio file", required=True, nargs='+')
parser.add_argument("--lang", type=str, help="audio language", required=True)
parser.add_argument("--format", type=str, choices=["none", "letter"], default="letter")
parser.add_argument("--extra-infer-args", type=str, default="")
return parser.parse_args()

def reorder_decode(hypos):
Expand All @@ -45,7 +46,7 @@ def process(args):
with open(tmpdir / "dev.wrd", "w") as fw:
fw.write("dummy dummy\n"*len(args.audio))
cmd = f"""
PYTHONPATH=. PREFIX=INFER HYDRA_FULL_ERROR=1 python examples/speech_recognition/new/infer.py -m --config-dir examples/mms/asr/config/ --config-name infer_common decoding.type=viterbi dataset.max_tokens=1440000 distributed_training.distributed_world_size=1 "common_eval.path='{args.model}'" task.data={tmpdir} dataset.gen_subset="{args.lang}:dev" common_eval.post_process={args.format} decoding.results_path={tmpdir}
PYTHONPATH=. PREFIX=INFER HYDRA_FULL_ERROR=1 python examples/speech_recognition/new/infer.py -m --config-dir examples/mms/asr/config/ --config-name infer_common decoding.type=viterbi dataset.max_tokens=1440000 distributed_training.distributed_world_size=1 "common_eval.path='{args.model}'" task.data={tmpdir} dataset.gen_subset="{args.lang}:dev" common_eval.post_process={args.format} decoding.results_path={tmpdir} {args.extra_infer_args}
"""
print(">>> loading model & running inference ...", file=sys.stderr)
subprocess.run(cmd, shell=True, stdout=subprocess.DEVNULL,)
Expand Down

0 comments on commit 35641fb

Please sign in to comment.