code: def wav_to_spec(wav_audio, hparams):
      """Transforms the contents of a wav file into a series of spectrograms."""
      if hparams.spec_type == "raw":
          spec = _wav_to_framed_samples(wav_audio, hparams)
      else:
          if hparams.spec_type == "cqt":
              spec = _wav_to_cqt(wav_audio, hparams)
          elif hparams.spec_type == "mel":
              spec = _wav_to_mel(wav_audio, hparams)
          else:
              raise ValueError(
                  "Invalid spec_type: {}".format(hparams.spec_type)
              )
  
          if hparams.spec_log_amplitude:
              spec = librosa.power_to_db(spec)
  
      return spec
  
imports: import collections
  import functools
  import io
  import re
  import wave
  import zlib
  import librosa
  from magenta.models.onsets_frames_transcription import audio_transform
  from magenta.models.onsets_frames_transcription import constants
  from magenta.models.onsets_frames_transcription import drum_mappings
  from magenta.models.onsets_frames_transcription import melspec_input
  from note_seq import audio_io
  from note_seq import sequences_lib
  from note_seq.protobuf import music_pb2
  import numpy
  import tensorflow.compat.v1
label_desc: Use image node_id 6 for calling a global function with example usage: wav_to_spec(wav_audio, hparams) and returns: spec