def asr_wav_files(file_list, gpu_id, total_files, model_id):
    """Transcribe wav files in a list"""
    device = f"cuda:{gpu_id}" if torch.cuda.is_available() else "cpu"
    whisper_model, processor = init_whisper(model_id, device)
    print(f"Processing on {device} starts")
    start_time = time.time()
    for audio_file in file_list:
        try:
            transcription = transcribe_audio(
                whisper_model, processor, audio_file, device
            )
            write_transcription(audio_file, transcription)
            with lock:
                processed_files_count.value += 1
                if processed_files_count.value % 5 == 0:
                    current_time = time.time()
                    avg_time_per_file = (current_time - start_time) / (
                        processed_files_count.value
                    )
                    remaining_files = total_files - processed_files_count.value
                    estimated_time_remaining = avg_time_per_file * remaining_files
                    remaining_time_formatted = time.strftime(
                        "%H:%M:%S", time.gmtime(estimated_time_remaining)
                    )
                    print(
                        f"Processed {processed_files_count.value}/{total_files} files, time: {time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())}, Estimated time remaining: {remaining_time_formatted}"
                    )
        except Exception as e:
            print(f"Error processing file {audio_file}: {e}")
Transcribe wav files in a list
utils/whisper_transcription.py