class_docstr: Writer class for 'midi.scp'
  
  Examples:
      key1 /some/path/a.musicxml
      key2 /some/path/b.musicxml
      key3 /some/path/c.musicxml
      key4 /some/path/d.musicxml
      ...
  
      >>> writer = XMLScpWriter('./data/', './data/xml.scp')
      >>> writer['aa'] = xml_obj
      >>> writer['bb'] = xml_obj
class_docstr_tok: ["Writer","class","for","'midi.scp'","Examples",":","key1","\/some\/path\/a.musicxml","key2","\/some\/path\/b.musicxml","key3","\/some\/path\/c.musicxml","key4","\/some\/path\/d.musicxml","...",">",">",">","writer","=","XMLScpWriter","(","'.\/data\/","'",",","'.\/data\/xml.scp","'",")",">",">",">","writer","[","'aa","'","]","=","xml_obj",">",">",">","writer","[","'bb","'","]","=","xml_obj"]
code: def __setitem__(self, key: str, value: tuple):
      assert (
          len(value) == 4
      ), "The xml values should include lyrics, note, segmentations and tempo"
      lyrics_seq, notes_seq, segs_seq, tempo = value
      xml_path = self.dir / f"{key}.musicxml"
      xml_path.parent.mkdir(parents=True, exist_ok=True)
  
      m = m21.stream.Stream()
      m.insert(m21.tempo.MetronomeMark(number=tempo))
      bps = 1.0 * tempo / 60
      offset = 0
      for i in range(len(lyrics_seq)):
          duration = int(
              8 * (segs_seq[i][1] - segs_seq[i][0]) * bps + 0.5
          )
          duration = 1.0 * duration / 8
          if duration == 0:
              duration = 1 / 16
          if notes_seq[i] != 0:  # isNote
              n = m21.note.Note(notes_seq[i])
              if lyrics_seq[i] != "—":
                  n.lyric = lyrics_seq[i]
          else:  # isRest
              n = m21.note.Rest()
          n.offset = offset
          n.duration = m21.duration.Duration(duration)
          m.insert(n)
          offset += duration
      m.write("xml", fp=xml_path)
      self.fscp.write(f"{key} {xml_path}\n")
      self.data[key] = str(xml_path)
  
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 XMLWriter obj's underlying member method code with example usage: obj.__setitem__(key, value) without return types