code: def text2mel(
      text: str,
      lexicon_fn=FLAGS.data_dir / "lexicon.txt",
      silence_duration: float = -1.0,
      acoustic_ckpt=FLAGS.ckpt_dir / "acoustic_latest_ckpt.pickle",
      duration_ckpt=FLAGS.ckpt_dir / "duration_latest_ckpt.pickle",
  ):
      tokens = text2tokens(text, lexicon_fn)
      durations = predict_duration(tokens, duration_ckpt)
      durations = jnp.where(
          np.array(tokens)[None, :] == FLAGS.sil_index,
          jnp.clip(durations, a_min=silence_duration, a_max=None),
          durations,
      )
      durations = jnp.where(
          np.array(tokens)[None, :] == FLAGS.word_end_index,
          0.0,
          durations,
      )
      mels = predict_mel(tokens, durations, acoustic_ckpt)
      if tokens[-1] == FLAGS.sil_index:
          end_silence = durations[0, -1].item()
          silence_frame = int(
              end_silence * FLAGS.sample_rate / (FLAGS.n_fft // 4)
          )
          mels = mels[:, : (mels.shape[1] - silence_frame)]
      return mels
  
file_path: underthesea/underthesea/pipeline/say/viettts_/nat/text2mel.py
imports: import pickle
  from argparse import ArgumentParser
  from pathlib import Path
  import haiku
  import jax
  import jax.numpy
  import matplotlib.pyplot
  import numpy
  from .config import FLAGS, DurationInput
  from .data_loader import load_phonemes_set
  from .model import AcousticModel, DurationModel
label_desc: Use image node_id 5 for calling a global function with example usage: text2mel(text, lexicon_fn, silence_duration, acoustic_ckpt, duration_ckpt) and returns: mels