code: def segment_file_grouped(src_file, segment_list):
      # Read the audio
      sr, audio_data = wavfile.read(src_file)
  
      for seg, tgt_file in segment_list:
          # Create tgt dir
          tgt_file.parent.mkdir(parents=True, exist_ok=True)
  
          # Get segment info
          assert seg[0] == "(" and seg[-1] == ")", (
              src_file,
              seg,
              tgt_file,
          )
          seg = seg[1:-1].split(",")
          assert len(seg) in [2, 3]
  
          # Get start and end frames from segment
          start_time, end_time = seg[:2]
          start_time = (
              float(start_time.rstrip("s"))
              if start_time != ""
              else None
          )
          start_frame = round(start_time * sr) if start_time else 0
          end_time = (
              float(end_time.rstrip("s")) if end_time != "" else None
          )
          end_frame = (
              round(end_time * sr) if end_time else len(audio_data)
          )
  
          # Get segmented audio data
          seg_data = audio_data[start_frame:end_frame]
          if len(seg) == 3:
              assert seg[2] in ["1", "2"], seg
              channel = int(seg[2]) - 1
              seg_data = seg_data[:, channel]
  
          # Write the segmented audio data
          if len(seg_data) > 0:
              wavfile.write(tgt_file, sr, seg_data)
  
file_path: textlesslib/examples/expresso/dataset/processing/perform_operations.py
imports: import os
  import shutil
  from pathlib import Path
  from collections import defaultdict
  import scipy.io.wavfile
  from multiprocessing import Pool
  from tqdm import tqdm
  from time import time
label_desc: Use image node_id 5 for calling a global function with example usage: segment_file_grouped(src_file, segment_list) without return types