docstr: :param inp: {'text': str, 'item_name': (str, optional), 'spk_name': (str, optional)}
  :return:
docstr_tok: [":","param","inp",":","{","'text","'",":","str",",","'item_name","'",":","(","str",",","optional",")",",","'spk_name","'",":","(","str",",","optional",")","}",":","return",":"]
code: def preprocess_input(self, inp, input_type="word"):
      """
  
      :param inp: {'text': str, 'item_name': (str, optional), 'spk_name': (str, optional)}
      :return:
      """
  
      item_name = inp.get("item_name", "<ITEM_NAME>")
      spk_name = inp.get("spk_name", "opencpop")
  
      # single spk
      spk_id = self.spk_map[spk_name]
  
      # get ph seq, note lst, midi dur lst, is slur lst.
      if input_type == "word":
          ret = self.preprocess_word_level_input(inp)
      # like transcriptions.txt in Opencpop dataset.
      elif input_type == "phoneme":
          ret = self.preprocess_phoneme_level_input(inp)
      else:
          print("Invalid input type.")
          return None
  
      if ret:
          ph_seq, note_lst, midi_dur_lst, is_slur = ret
      else:
          print(
              "==========> Preprocess_word_level or phone_level input wrong."
          )
          return None
  
      # convert note lst to midi id; convert note dur lst to midi duration
      try:
          midis = [
              librosa.note_to_midi(x.split("/")[0])
              if x != "rest"
              else 0
              for x in note_lst
          ]
          midi_dur_lst = [float(x) for x in midi_dur_lst]
      except Exception as e:
          print(e)
          print("Invalid Input Type.")
          return None
  
      ph_token = self.ph_encoder.encode(ph_seq)
      item = {
          "item_name": item_name,
          "text": inp["text"],
          "ph": ph_seq,
          "spk_id": spk_id,
          "ph_token": ph_token,
          "pitch_midi": np.asarray(midis),
          "midi_dur": np.asarray(midi_dur_lst),
          "is_slur": np.asarray(is_slur),
      }
      item["ph_len"] = len(item["ph_token"])
      return item
  
imports: import os
  from collections import deque
  import librosa
  import numpy
  import onnxruntime
  from pypinyin import lazy_pinyin
  from tqdm import tqdm
  from .inference.svs.opencpop.map import cpop_pinyin2ph_func
  from .utils.hparams import hparams
  from .utils.text_encoder import TokenTextEncoder
label_desc: Use image node_id 9 for calling the Infer obj's underlying member method code with example usage: obj.preprocess_input(inp, input_type) and returns: item, None, None, None