code: def _extract_train_text(tedlium_path, output_dir):
      stm_path = tedlium_path / "TEDLIUM_release-3/data/stm/"
      transcripts = []
      for file in sorted(os.listdir(stm_path)):
          if file.endswith(".stm"):
              file = os.path.join(stm_path, file)
              with open(file) as f:
                  for line in f.readlines():
                      (
                          talk_id,
                          _,
                          speaker_id,
                          start_time,
                          end_time,
                          identifier,
                          transcript,
                      ) = line.split(" ", 6)
                      if (
                          transcript
                          == "ignore_time_segment_in_scoring\n"
                      ):
                          continue
                      else:
                          transcript = transcript.replace(
                              "<unk>", "<garbage>"
                          ).replace("\n", "")
                          transcripts.append(transcript)
  
      return transcripts
  
file_path: audio/examples/asr/emformer_rnnt/tedlium3/train_spm.py
imports: import io
  import logging
  import os
  import pathlib
  from argparse import ArgumentParser, RawTextHelpFormatter
  import sentencepiece
label_desc: Use image node_id 2 for calling a global function with example usage: _extract_train_text(tedlium_path, output_dir) and returns: transcripts