def asr_main(input_dir, num_gpus, model_id):
    """Transcribe wav files in a directory"""
    num_processes = min(num_gpus, os.cpu_count())
    print(f"Using {num_processes} GPUs for transcription")
    wav_files = list(pathlib.Path(input_dir).rglob("*.wav"))
    total_files = len(wav_files)
    print(f"Found {total_files} wav files in {input_dir}")
    files_per_process = len(wav_files) // num_processes
    print(f"Processing {files_per_process} files per process")
    with Pool(num_processes) as p:
        p.starmap(
            asr_wav_files,
            [
                (
                    wav_files[i * files_per_process : (i + 1) * files_per_process],
                    i % num_gpus,
                    total_files,
                    model_id,
                )
                for i in range(num_processes)
            ],
        )
    print("Done!")
Transcribe wav files in a directory
utils/whisper_transcription.py