class_docstr: Reader class for 'xml.scp'.
  
  Examples:
      key1 /some/path/a.xml
      key2 /some/path/b.xml
      key3 /some/path/c.xml
      key4 /some/path/d.xml
      ...
  
      >>> reader = XMLScpReader('xml.scp')
      >>> tempo, note_list = reader['key1']
class_docstr_tok: ["Reader","class","for","'xml.scp","'",".","Examples",":","key1","\/some\/path\/a.xml","key2","\/some\/path\/b.xml","key3","\/some\/path\/c.xml","key4","\/some\/path\/d.xml","...",">",">",">","reader","=","XMLScpReader","(","'xml.scp","'",")",">",">",">","tempo",",","note_list","=","reader","[","'key1","'","]"]
code: def __getitem__(self, key):
      score = m21.converter.parse(self.data[key])
      m = score.metronomeMarkBoundaries()
      tempo = int(m[0][2].number)
      part = score.parts[0].flat
      notes_list = []
      prepitch = -1
      st = 0
      for note in part.notesAndRests:
          dur = note.seconds
          if not note.isRest:  # Note or Chord
              lr = note.lyric
              if note.isChord:
                  for n in note:
                      if n.pitch.midi != prepitch:  # Ignore repeat note
                          note = n
                          break
              if (
                  lr is None or lr == "" or lr == "ー"
              ):  # multi note in one syllable
                  if note.pitch.midi == prepitch:  # same pitch
                      notes_list[-1].et += dur
                  else:  # different pitch
                      notes_list.append(
                          NOTE("—", note.pitch.midi, st, st + dur)
                      )
              elif lr == "br":  # <br> is tagged as a note
                  if prepitch == 0:
                      notes_list[-1].et += dur
                  else:
                      notes_list.append(NOTE("P", 0, st, st + dur))
                  prepitch = 0
                  st += dur
                  continue
              else:  # normal note for one syllable
                  notes_list.append(
                      NOTE(lr, note.pitch.midi, st, st + dur)
                  )
              prepitch = note.pitch.midi
              for arti in note.articulations:
                  # NOTE(Yuning): By default, 'breath mark' appears at the end of
                  # the sentence. In some situations, 'breath mark' doesn't take
                  # effect in its belonging note. Please handle them under local/.
                  if arti.name in [
                      "breath mark"
                  ]:  # <br> is tagged as a notation
                      notes_list.append(
                          NOTE("B", 0, st + dur, st + dur)
                      )
                  # NOTE(Yuning): In some datasets, there is a break when 'staccato'
                  # occurs. We let users to decide whether to perform segmentation
                  # under local/.
          else:  # rest note
              if prepitch == 0:
                  notes_list[-1].et += dur
              else:
                  notes_list.append(NOTE("P", 0, st, st + dur))
              prepitch = 0
          st += dur
      # NOTE(Yuning): implicit rest at the end of xml file should be removed.
      if notes_list[-1].midi == 0 and notes_list[-1].lyric == "P":
          notes_list.pop()
      return tempo, notes_list
  
imports: import collections.abc
  import json
  from pathlib import Path
  from typing import Union
  import numpy
  from typeguard import check_argument_types
  from espnet2.fileio.read_text import read_2columns_text
label_desc: Use image node_id 2 for calling the XMLReader obj's underlying member method code with example usage: obj.__getitem__(key) and returns: tempo,  notes_list