2525"""
2626
2727import argparse
28+ import copy
2829import json
2930import os
3031import shutil
@@ -155,12 +156,14 @@ def create_manifest_entry(
155156 Manifest entry dict with proper format for nemo-skills
156157 """
157158 instruction = sample .get ("instruction" , sample .get ("text" , "Process the audio" ))
159+ if isinstance (instruction , dict ):
160+ instruction = instruction .get ("text" ) or "Process the audio"
158161 reference = sample .get ("reference" , sample .get ("answer" , "" ))
159162 task_type = sample .get ("task_type" , "unknown" )
160163
161- # Create absolute audio path with /data/ prefix for cluster deployment
162- # Format: /data/ audiobench/{category}/audio/{dataset_name}/{filename}
163- audio_rel_path = f"/data/audiobench/ { category } / audio/{ dataset_name } /{ audio_filename } "
164+ # Paths are resolved relative to the manifest directory by the inference code.
165+ # The combined category manifest lives at audiobench/{category}/test.jsonl.
166+ audio_rel_path = f"audio/{ dataset_name } /{ audio_filename } "
164167
165168 # Create audio metadata (both singular and plural forms for compatibility)
166169 audio_metadata = {"path" : audio_rel_path , "duration" : duration }
@@ -203,6 +206,28 @@ def create_manifest_entry(
203206 return entry
204207
205208
209+ def make_dataset_manifest_entry (entry : Dict ) -> Dict :
210+ """Adjust category-relative audio paths for per-dataset manifests."""
211+ entry = copy .deepcopy (entry )
212+
213+ def rewrite (path : str ) -> str :
214+ return f"../{ path } " if path .startswith ("audio/" ) else path
215+
216+ if isinstance (entry .get ("audio_path" ), list ):
217+ entry ["audio_path" ] = [rewrite (path ) for path in entry ["audio_path" ]]
218+ elif isinstance (entry .get ("audio_path" ), str ):
219+ entry ["audio_path" ] = rewrite (entry ["audio_path" ])
220+
221+ for message in entry .get ("messages" , []):
222+ if "audio" in message and "path" in message ["audio" ]:
223+ message ["audio" ]["path" ] = rewrite (message ["audio" ]["path" ])
224+ for audio in message .get ("audios" , []):
225+ if "path" in audio :
226+ audio ["path" ] = rewrite (audio ["path" ])
227+
228+ return entry
229+
230+
206231def process_dataset (
207232 dataset_name : str ,
208233 output_dir : Path ,
@@ -473,7 +498,7 @@ def process_dataset(
473498 manifest_path = dataset_dir / f"{ split } .jsonl"
474499 with open (manifest_path , "w" , encoding = "utf-8" ) as f :
475500 for entry in manifest_entries :
476- f .write (json .dumps (entry , ensure_ascii = False ) + "\n " )
501+ f .write (json .dumps (make_dataset_manifest_entry ( entry ) , ensure_ascii = False ) + "\n " )
477502
478503 print (f"✓ Saved { successful } samples to { manifest_path } " )
479504 if failed > 0 :
@@ -566,6 +591,7 @@ def main():
566591
567592 total_samples = 0
568593 total_datasets = 0
594+ combined_entries = {"judge" : [], "nonjudge" : []}
569595
570596 for name in target_datasets :
571597 # Normalize dataset name: allow passing without _test suffix
@@ -576,10 +602,10 @@ def main():
576602 dataset_name = f"{ dataset_name } _test"
577603
578604 # Determine category for logging
579- category = "judge" if name in JUDGE_DATASETS else "nonjudge"
605+ category = "judge" if dataset_name in JUDGE_DATASETS else "nonjudge"
580606
581607 try :
582- num_samples , _ = process_dataset (
608+ num_samples , manifest_entries = process_dataset (
583609 dataset_name = dataset_name ,
584610 output_dir = output_dir ,
585611 save_audio = args .save_audio ,
@@ -588,11 +614,21 @@ def main():
588614 )
589615 total_samples += num_samples
590616 total_datasets += 1
617+ combined_entries [category ].extend (manifest_entries )
591618 print (f"✓ Completed { dataset_name } : { num_samples } samples" )
592619 except Exception as e :
593620 print (f"✗ Failed { dataset_name } : { e } " )
594621 continue
595622
623+ for category , entries in combined_entries .items ():
624+ if not entries :
625+ continue
626+ combined_manifest = output_dir / category / f"{ args .split } .jsonl"
627+ with open (combined_manifest , "w" , encoding = "utf-8" ) as f :
628+ for entry in entries :
629+ f .write (json .dumps (entry , ensure_ascii = False ) + "\n " )
630+ print (f"✓ Saved combined { category } manifest with { len (entries )} samples to { combined_manifest } " )
631+
596632 print ("\n " + "=" * 60 )
597633 print ("AudioBench Preparation Summary" )
598634 print ("=" * 60 )
0 commit comments