def decode(model_path_prefix: Union[str, Path],
           input_paths: Sequence[Path],
           label_set: Set[str],
           *,
           feature_type: str = "fbank", #TODO Make this None and infer feature_type from dimension of NN input layer.
           batch_size: int = 64,
           feat_dir: Optional[Path]=None,
           batch_x_name: str="batch_x:0",
           batch_x_lens_name: str="batch_x_lens:0",
           output_name: str="hyp_dense_decoded:0") -> List[List[str]]:
    """Use an existing tensorflow model that exists on disk to decode
    WAV files.

    Args:
        model_path_prefix: The path to the saved tensorflow model.
                           This is the full prefix to the ".ckpt" file.
        input_paths: A sequence of `pathlib.Path`s to WAV files to put through
                     the model provided.
        label_set: The set of all the labels this model uses.
        feature_type: The type of features this model uses.
                      Note that this MUST match the type of features that the
                      model was trained on initially.
        feat_dir: Any files that require preprocessing will be
                                  saved to the path specified by this.
        batch_x_name: The name of the tensorflow input for batch_x
        batch_x_lens_name: The name of the tensorflow input for batch_x_lens
        output_name: The name of the tensorflow output
    """

    if not input_paths:
        raise PersephoneException("No untranscribed WAVs to transcribe.")

    model_path_prefix = str(model_path_prefix)

    for p in input_paths:
        if not p.exists():
            raise PersephoneException(
                "The WAV file path {} does not exist".format(p)
            )

    preprocessed_file_paths = []
    for p in input_paths:
        prefix = p.stem
        # Check the "feat" directory as per the filesystem conventions of a Corpus
        feature_file_ext = ".{}.npy".format(feature_type)
        conventional_npy_location =  p.parent.parent / "feat" / (Path(prefix + feature_file_ext))
        if conventional_npy_location.exists():
            # don't need to preprocess it
            preprocessed_file_paths.append(conventional_npy_location)
        else:
            if not feat_dir:
                feat_dir = p.parent.parent / "feat"
            if not feat_dir.is_dir():
                os.makedirs(str(feat_dir))

            mono16k_wav_path = feat_dir / "{}.wav".format(prefix)
            feat_path = feat_dir / "{}.{}.npy".format(prefix, feature_type)
            feat_extract.convert_wav(p, mono16k_wav_path)
            preprocessed_file_paths.append(feat_path)
    # preprocess the file that weren't found in the features directory
    # as per the filesystem conventions
    if feat_dir:
        feat_extract.from_dir(feat_dir, feature_type)

    fn_batches = utils.make_batches(preprocessed_file_paths, batch_size)
    # Load the model and perform decoding.
    metagraph = load_metagraph(model_path_prefix)
    with tf.Session() as sess:
        metagraph.restore(sess, model_path_prefix)

        for fn_batch in fn_batches:
            batch_x, batch_x_lens = utils.load_batch_x(fn_batch)

        # TODO These placeholder names should be a backup if names from a newer
        # naming scheme aren't present. Otherwise this won't generalize to
        # different architectures.
        feed_dict = {batch_x_name: batch_x,
                     batch_x_lens_name: batch_x_lens}

        dense_decoded = sess.run(output_name, feed_dict=feed_dict)

    # Create a human-readable representation of the decoded.
    indices_to_labels = labels.make_indices_to_labels(label_set)
    human_readable = dense_to_human_readable(dense_decoded, indices_to_labels)

    return human_readable
Use an existing tensorflow model that exists on disk to decode
    WAV files.

    Args:
        model_path_prefix: The path to the saved tensorflow model.
                           This is the full prefix to the ".ckpt" file.
        input_paths: A sequence of `pathlib.Path`s to WAV files to put through
                     the model provided.
        label_set: The set of all the labels this model uses.
        feature_type: The type of features this model uses.
                      Note that this MUST match the type of features that the
                      model was trained on initially.
        feat_dir: Any files that require preprocessing will be
                                  saved to the path specified by this.
        batch_x_name: The name of the tensorflow input for batch_x
        batch_x_lens_name: The name of the tensorflow input for batch_x_lens
        output_name: The name of the tensorflow output