We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
MMS Multiple voice inputs problem
When I use the following command：
python examples/mms/asr/infer/mms_infer.py --model "/path/to/asr/model" --lang lang_code --audio "/path/to/audio_1.wav" "/path/to/audio_1.wav"
The result is disorder. How to correspond one by one.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `examples/mms/asr/infer/mms_infer.py`
Content:
```
1 #!/usr/bin/env python -u
2 # Copyright (c) Facebook, Inc. and its affiliates.
3 #
4 # This source code is licensed under the MIT license found in the
5 # LICENSE file in the root directory of this source tree.
6 
7 import argparse
8 import soundfile as sf
9 import tempfile
10 from pathlib import Path
11 import os
12 import subprocess
13 import sys
14 import re
15 
16 def parser():
17     parser = argparse.ArgumentParser(description="ASR inference script for MMS model")
18     parser.add_argument("--model", type=str, help="path to ASR model", required=True)
19     parser.add_argument("--audio", type=str, help="path to audio file", required=True, nargs='+')
20     parser.add_argument("--lang", type=str, help="audio language", required=True)
21     parser.add_argument("--format", type=str, choices=["none", "letter"], default="letter")
22     return parser.parse_args()
23 
24 def process(args):    
25     with tempfile.TemporaryDirectory() as tmpdir:
26         print(">>> preparing tmp manifest dir ...", file=sys.stderr)
27         tmpdir = Path(tmpdir)
28         with open(tmpdir / "dev.tsv", "w") as fw:
29             fw.write("/\n")
30             for audio in args.audio:
31                 nsample = sf.SoundFile(audio).frames
32                 fw.write(f"{audio}\t{nsample}\n")
33         with open(tmpdir / "dev.uid", "w") as fw:
34             fw.write(f"{audio}\n"*len(args.audio))
35         with open(tmpdir / "dev.ltr", "w") as fw:
36             fw.write("d u m m y | d u m m y\n"*len(args.audio))
37         with open(tmpdir / "dev.wrd", "w") as fw:
38             fw.write("dummy dummy\n"*len(args.audio))
39         cmd = f"""
40         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=4000000 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}
41         """
42         print(">>> loading model & running inference ...", file=sys.stderr)
43         subprocess.run(cmd, shell=True, stdout=subprocess.DEVNULL,)
44         with open(tmpdir/"hypo.word") as fr:
45             for ii, hypo in enumerate(fr):
46                 hypo = re.sub("\(\S+\)$", "", hypo).strip()
47                 print(f'===============\nInput: {args.audio[ii]}\nOutput: {hypo}')
48 
49 
50 if __name__ == "__main__":
51     args = parser()
52     process(args)
53
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/examples/mms/asr/infer/mms_infer.py b/examples/mms/asr/infer/mms_infer.py
--- a/examples/mms/asr/infer/mms_infer.py
+++ b/examples/mms/asr/infer/mms_infer.py
@@ -21,28 +21,38 @@
     parser.add_argument("--format", type=str, choices=["none", "letter"], default="letter")
     return parser.parse_args()
 
+def reorder_decode(hypos):
+    outputs = []
+    for hypo in hypos:
+        idx = int(re.findall("\(None-(\d+)\)$", hypo)[0])
+        hypo = re.sub("\(\S+\)$", "", hypo).strip()
+        outputs.append((idx, hypo))
+    outputs = sorted(outputs)
+    return outputs
+
 def process(args):    
     with tempfile.TemporaryDirectory() as tmpdir:
         print(">>> preparing tmp manifest dir ...", file=sys.stderr)
         tmpdir = Path(tmpdir)
-        with open(tmpdir / "dev.tsv", "w") as fw:
+        with open(tmpdir / "dev.tsv", "w") as fw, open(tmpdir / "dev.uid", "w") as fu:
             fw.write("/\n")
             for audio in args.audio:
                 nsample = sf.SoundFile(audio).frames
                 fw.write(f"{audio}\t{nsample}\n")
-        with open(tmpdir / "dev.uid", "w") as fw:
-            fw.write(f"{audio}\n"*len(args.audio))
+                fu.write(f"{audio}\n")
         with open(tmpdir / "dev.ltr", "w") as fw:
-            fw.write("d u m m y | d u m m y\n"*len(args.audio))
+            fw.write("d u m m y | d u m m y |\n"*len(args.audio))
         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=4000000 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}
         """
         print(">>> loading model & running inference ...", file=sys.stderr)
         subprocess.run(cmd, shell=True, stdout=subprocess.DEVNULL,)
         with open(tmpdir/"hypo.word") as fr:
-            for ii, hypo in enumerate(fr):
+            hypos = fr.readlines()
+            outputs = reorder_decode(hypos)
+            for ii, hypo in outputs:
                 hypo = re.sub("\(\S+\)$", "", hypo).strip()
                 print(f'===============\nInput: {args.audio[ii]}\nOutput: {hypo}')

{"golden_diff": "diff --git a/examples/mms/asr/infer/mms_infer.py b/examples/mms/asr/infer/mms_infer.py\n--- a/examples/mms/asr/infer/mms_infer.py\n+++ b/examples/mms/asr/infer/mms_infer.py\n@@ -21,28 +21,38 @@\n     parser.add_argument(\"--format\", type=str, choices=[\"none\", \"letter\"], default=\"letter\")\n     return parser.parse_args()\n \n+def reorder_decode(hypos):\n+    outputs = []\n+    for hypo in hypos:\n+        idx = int(re.findall(\"\\(None-(\\d+)\\)$\", hypo)[0])\n+        hypo = re.sub(\"\\(\\S+\\)$\", \"\", hypo).strip()\n+        outputs.append((idx, hypo))\n+    outputs = sorted(outputs)\n+    return outputs\n+\n def process(args):    \n     with tempfile.TemporaryDirectory() as tmpdir:\n         print(\">>> preparing tmp manifest dir ...\", file=sys.stderr)\n         tmpdir = Path(tmpdir)\n-        with open(tmpdir / \"dev.tsv\", \"w\") as fw:\n+        with open(tmpdir / \"dev.tsv\", \"w\") as fw, open(tmpdir / \"dev.uid\", \"w\") as fu:\n             fw.write(\"/\\n\")\n             for audio in args.audio:\n                 nsample = sf.SoundFile(audio).frames\n                 fw.write(f\"{audio}\\t{nsample}\\n\")\n-        with open(tmpdir / \"dev.uid\", \"w\") as fw:\n-            fw.write(f\"{audio}\\n\"*len(args.audio))\n+                fu.write(f\"{audio}\\n\")\n         with open(tmpdir / \"dev.ltr\", \"w\") as fw:\n-            fw.write(\"d u m m y | d u m m y\\n\"*len(args.audio))\n+            fw.write(\"d u m m y | d u m m y |\\n\"*len(args.audio))\n         with open(tmpdir / \"dev.wrd\", \"w\") as fw:\n             fw.write(\"dummy dummy\\n\"*len(args.audio))\n         cmd = f\"\"\"\n-        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=4000000 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}\n+        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}\n         \"\"\"\n         print(\">>> loading model & running inference ...\", file=sys.stderr)\n         subprocess.run(cmd, shell=True, stdout=subprocess.DEVNULL,)\n         with open(tmpdir/\"hypo.word\") as fr:\n-            for ii, hypo in enumerate(fr):\n+            hypos = fr.readlines()\n+            outputs = reorder_decode(hypos)\n+            for ii, hypo in outputs:\n                 hypo = re.sub(\"\\(\\S+\\)$\", \"\", hypo).strip()\n                 print(f'===============\\nInput: {args.audio[ii]}\\nOutput: {hypo}')\n", "issue": "MMS Multiple voice inputs problem\nWhen I use the following command\uff1a\r\npython examples/mms/asr/infer/mms_infer.py --model \"/path/to/asr/model\" --lang lang_code --audio \"/path/to/audio_1.wav\" \"/path/to/audio_1.wav\"\r\nThe result is disorder. How to correspond one by one.\r\n\n", "before_files": [{"content": "#!/usr/bin/env python -u\n# Copyright (c) Facebook, Inc. and its affiliates.\n#\n# This source code is licensed under the MIT license found in the\n# LICENSE file in the root directory of this source tree.\n\nimport argparse\nimport soundfile as sf\nimport tempfile\nfrom pathlib import Path\nimport os\nimport subprocess\nimport sys\nimport re\n\ndef parser():\n    parser = argparse.ArgumentParser(description=\"ASR inference script for MMS model\")\n    parser.add_argument(\"--model\", type=str, help=\"path to ASR model\", required=True)\n    parser.add_argument(\"--audio\", type=str, help=\"path to audio file\", required=True, nargs='+')\n    parser.add_argument(\"--lang\", type=str, help=\"audio language\", required=True)\n    parser.add_argument(\"--format\", type=str, choices=[\"none\", \"letter\"], default=\"letter\")\n    return parser.parse_args()\n\ndef process(args):    \n    with tempfile.TemporaryDirectory() as tmpdir:\n        print(\">>> preparing tmp manifest dir ...\", file=sys.stderr)\n        tmpdir = Path(tmpdir)\n        with open(tmpdir / \"dev.tsv\", \"w\") as fw:\n            fw.write(\"/\\n\")\n            for audio in args.audio:\n                nsample = sf.SoundFile(audio).frames\n                fw.write(f\"{audio}\\t{nsample}\\n\")\n        with open(tmpdir / \"dev.uid\", \"w\") as fw:\n            fw.write(f\"{audio}\\n\"*len(args.audio))\n        with open(tmpdir / \"dev.ltr\", \"w\") as fw:\n            fw.write(\"d u m m y | d u m m y\\n\"*len(args.audio))\n        with open(tmpdir / \"dev.wrd\", \"w\") as fw:\n            fw.write(\"dummy dummy\\n\"*len(args.audio))\n        cmd = f\"\"\"\n        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=4000000 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}\n        \"\"\"\n        print(\">>> loading model & running inference ...\", file=sys.stderr)\n        subprocess.run(cmd, shell=True, stdout=subprocess.DEVNULL,)\n        with open(tmpdir/\"hypo.word\") as fr:\n            for ii, hypo in enumerate(fr):\n                hypo = re.sub(\"\\(\\S+\\)$\", \"\", hypo).strip()\n                print(f'===============\\nInput: {args.audio[ii]}\\nOutput: {hypo}')\n\n\nif __name__ == \"__main__\":\n    args = parser()\n    process(args)\n", "path": "examples/mms/asr/infer/mms_infer.py"}], "after_files": [{"content": "#!/usr/bin/env python -u\n# Copyright (c) Facebook, Inc. and its affiliates.\n#\n# This source code is licensed under the MIT license found in the\n# LICENSE file in the root directory of this source tree.\n\nimport argparse\nimport soundfile as sf\nimport tempfile\nfrom pathlib import Path\nimport os\nimport subprocess\nimport sys\nimport re\n\ndef parser():\n    parser = argparse.ArgumentParser(description=\"ASR inference script for MMS model\")\n    parser.add_argument(\"--model\", type=str, help=\"path to ASR model\", required=True)\n    parser.add_argument(\"--audio\", type=str, help=\"path to audio file\", required=True, nargs='+')\n    parser.add_argument(\"--lang\", type=str, help=\"audio language\", required=True)\n    parser.add_argument(\"--format\", type=str, choices=[\"none\", \"letter\"], default=\"letter\")\n    return parser.parse_args()\n\ndef reorder_decode(hypos):\n    outputs = []\n    for hypo in hypos:\n        idx = int(re.findall(\"\\(None-(\\d+)\\)$\", hypo)[0])\n        hypo = re.sub(\"\\(\\S+\\)$\", \"\", hypo).strip()\n        outputs.append((idx, hypo))\n    outputs = sorted(outputs)\n    return outputs\n\ndef process(args):    \n    with tempfile.TemporaryDirectory() as tmpdir:\n        print(\">>> preparing tmp manifest dir ...\", file=sys.stderr)\n        tmpdir = Path(tmpdir)\n        with open(tmpdir / \"dev.tsv\", \"w\") as fw, open(tmpdir / \"dev.uid\", \"w\") as fu:\n            fw.write(\"/\\n\")\n            for audio in args.audio:\n                nsample = sf.SoundFile(audio).frames\n                fw.write(f\"{audio}\\t{nsample}\\n\")\n                fu.write(f\"{audio}\\n\")\n        with open(tmpdir / \"dev.ltr\", \"w\") as fw:\n            fw.write(\"d u m m y | d u m m y |\\n\"*len(args.audio))\n        with open(tmpdir / \"dev.wrd\", \"w\") as fw:\n            fw.write(\"dummy dummy\\n\"*len(args.audio))\n        cmd = f\"\"\"\n        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}\n        \"\"\"\n        print(\">>> loading model & running inference ...\", file=sys.stderr)\n        subprocess.run(cmd, shell=True, stdout=subprocess.DEVNULL,)\n        with open(tmpdir/\"hypo.word\") as fr:\n            hypos = fr.readlines()\n            outputs = reorder_decode(hypos)\n            for ii, hypo in outputs:\n                hypo = re.sub(\"\\(\\S+\\)$\", \"\", hypo).strip()\n                print(f'===============\\nInput: {args.audio[ii]}\\nOutput: {hypo}')\n\n\nif __name__ == \"__main__\":\n    args = parser()\n    process(args)\n", "path": "examples/mms/asr/infer/mms_infer.py"}]}