code: def make_durations(args):
      """Make durations file."""
  
      wavs_dir = Path(args.corpus_dir)
      textgrid_dir = args.textgrid_dir
      train_text_path = args.train_text_path
      durations_path = args.durations_path
  
      os.makedirs(os.path.dirname(train_text_path), exist_ok=True)
      with open(train_text_path, "w") as text_file:
          with open(durations_path, "w") as durations_file:
              lab_paths = sorted(wavs_dir.glob("**/*.lab"))
              assert (
                  len(lab_paths) > 0
              ), f"The folder {wavs_dir} does not contain any transcription."
              for lab_path in lab_paths:
                  wav_path = lab_path.as_posix().replace(
                      ".lab", ".wav"
                  )  # Assumes .wav files are in same dir as .lab files
                  if not os.path.exists(wav_path):
                      logging.warning(
                          "There is no wav file for %s, skipping.",
                          lab_path,
                      )
                      continue
  
                  # get no. of samples and original sr directly from audio file
                  with sf.SoundFile(wav_path) as audio:
                      orig_sr = audio.samplerate
                      # Account for downsampling
                      no_samples = int(
                          audio.frames * (args.samplerate / orig_sr)
                      )
  
                  filename = (
                      lab_path.as_posix()
                      .replace(args.corpus_dir.rstrip("/") + "/", "")
                      .replace(".lab", "")
                  )
                  with open(lab_path) as lab_file:
                      original_text = lab_file.read()
                  tg_path = os.path.join(
                      textgrid_dir, f"{filename}.json"
                  )
                  if not os.path.exists(tg_path):
                      logging.warning(
                          "There is no alignment for %s, skipping.",
                          lab_path,
                      )
                      continue
                  with codecs.open(
                      tg_path, "r", encoding="utf-8"
                  ) as reader:
                      _data_dict = json.load(reader)
                  new_phones, durations = get_phoneme_durations(
                      _data_dict,
                      original_text,
                      args.samplerate,
                      args.hop_size,
                      no_samples,
                  )
                  key = filename.split("/")[-1]
                  text_file.write(f'{key} {" ".join(new_phones)}\n')
                  durations = " ".join(str(d) for d in durations)
                  durations_file.write(f"{key} {durations} 0\n")
  
imports: import argparse
  import codecs
  import json
  import logging
  import os
  import re
  import sys
  import traceback
  from pathlib import Path
  from typing import Dict
  import kaldiio
  import soundfile
  from pyopenjtalk import run_frontend
  from espnet2.text.phoneme_tokenizer import PhonemeTokenizer
label_desc: Use image node_id 6 for calling a global function with example usage: make_durations(args) without return types