text: import tensorflow as tf
  import numpy as np
  
  from tensorflow import keras
  
  wavs_path = "C:\\Users\\hayle\\OneDrive\\Documents\\School\\hearRing\\Senior-Design\\src\\ml\\speech_rec\\ctc\\testing\\"
  # An integer scalar Tensor. The window length in samples.
  frame_length = 256
  # An integer scalar Tensor. The number of samples to step.
  frame_step = 160
  # An integer scalar Tensor. The size of the FFT to apply.
  # If not provided, uses the smallest power of 2 enclosing frame_length.
  fft_length = 384
  
  # The set of characters accepted in the transcription.
  characters = [x for x in "abcdefghijklmnopqrstuvwxyz'?! "]
  character_num_dict = {x+1 : characters[x] for x in range(len(characters))}
  character_num_dict[31] = ""
  # Mapping characters to integers
  char_to_num = keras.layers.StringLookup(vocabulary=characters, oov_token="")
  # Mapping integers back to original characters
  num_to_char = keras.layers.StringLookup(
      vocabulary=char_to_num.get_vocabulary(), oov_token="", invert=True
  )
  
  def encode_single_sample(wav_file, label):
      ###########################################
      ##  Process the Audio
      ##########################################
      # 1. Read wav file
      file = tf.io.read_file(wavs_path + wav_file + ".wav")
      # 2. Decode the wav file
      audio, _ = tf.audio.decode_wav(file)
      audio = tf.squeeze(audio, axis=-1)
      # 3. Change type to float
      audio = tf.cast(audio, tf.float32)
      # 4. Get the spectrogram
      spectrogram = tf.signal.stft(
          audio, frame_length=frame_length, frame_step=frame_step, fft_length=fft_length
      )
      # 5. We only need the magnitude, which can be derived by applying tf.abs
      spectrogram = tf.abs(spectrogram)
      spectrogram = tf.math.pow(spectrogram, 0.5)
      # 6. normalisation
      means = tf.math.reduce_mean(spectrogram, 1, keepdims=True)
      stddevs = tf.math.reduce_std(spectrogram, 1, keepdims=True)
      spectrogram = (spectrogram - means) / (stddevs + 1e-10)
      ###########################################
      ##  Process the label
      ##########################################
      # 7. Convert label to Lower case
      label = tf.strings.lower(label)
      # 8. Split the label
      label = tf.strings.unicode_split(label, input_encoding="UTF-8")
      # 9. Map the characters in label to numbers
      label = char_to_num(label)
      # 10. Return a dict as our model is expecting two inputs
      return spectrogram, label
  
  def CTCLoss(y_true, y_pred):
      # Compute the training-time loss value
      batch_len = tf.cast(tf.shape(y_true)[0], dtype="int64")
      input_length = tf.cast(tf.shape(y_pred)[1], dtype="int64")
      label_length = tf.cast(tf.shape(y_true)[1], dtype="int64")
  
      input_length = input_length * tf.ones(shape=(batch_len, 1), dtype="int64")
      label_length = label_length * tf.ones(shape=(batch_len, 1), dtype="int64")
  
      loss = keras.backend.ctc_batch_cost(y_true, y_pred, input_length, label_length)
      return loss
  
  def CTC_decode(inputs, input_length):
      pred_string = []
      prev_class_ix = -1
      for t in range(int(input_length)):
          row = inputs[0][t]
          max_index = max(range(len(row)), key=row.__getitem__)
          if (max_index != prev_class_ix and max_index != 31):
              pred_string.append(character_num_dict[max_index])
          prev_class_ix = max_index
      return "".join(pred_string)
      
  
  # A utility function to decode the output of the network
  def decode_batch_predictions(pred):
      input_len = np.ones(pred.shape[0]) * pred.shape[1]
      # Use greedy search. For complex tasks, you can use beam search
      results = keras.backend.ctc_decode(pred, input_length=input_len, greedy=True)[0][0]
      # Iterate over the results and get back the text
      output_text = []
      for result in results:
          result = tf.strings.reduce_join(num_to_char(result)).numpy().decode("utf-8")
          output_text.append(result)
      return output_text
  
  model = keras.models.load_model('C:\\Users\\hayle\\OneDrive\\Documents\\School\\hearRing\\Senior-Design\\src\\ml\\speech_rec\\ctc\\testing\\ctc_model.h5', custom_objects={'CTCLoss': CTCLoss})
  
  train_dataset = tf.data.Dataset.from_tensor_slices((["LJ001-0078"], [""]))
  train_dataset = (train_dataset.map(encode_single_sample, num_parallel_calls=tf.data.AUTOTUNE).padded_batch(1).prefetch(buffer_size=tf.data.AUTOTUNE))
  for data in train_dataset:
      x, y = data
      prediction = model.predict(x)
      print("Target: to improve the letter in form.")
      print("Prediction: " + str(decode_batch_predictions(prediction)[0]))
      print("Hayley Programmed CTC Decoding: " + CTC_decode(prediction, prediction.shape[1]))