class_docstr: A ready-to-use Encoder ASR model
  
  The class can be used either to run only the encoder (encode()) to extract
  features or to run the entire encoder + decoder function model
  (transcribe()) to transcribe speech. The given YAML must contain the fields
  specified in the *_NEEDED[] lists.
  
  Example
  -------
  >>> from speechbrain.inference.ASR import EncoderASR
  >>> tmpdir = getfixture("tmpdir")
  >>> asr_model = EncoderASR.from_hparams(
  ...     source="speechbrain/asr-wav2vec2-commonvoice-fr",
  ...     savedir=tmpdir,
  ... ) # doctest: +SKIP
  >>> asr_model.transcribe_file("samples/audio_samples/example_fr.wav") # doctest: +SKIP
class_docstr_tok: ["A","ready-to-use","Encoder","ASR","model","The","class","can","be","used","either","to","run","only","the","encoder","(","encode","(",")",")","to","extract","features","or","to","run","the","entire","encoder","+","decoder","function","model","(","transcribe","(",")",")","to","transcribe","speech",".","The","given","YAML","must","contain","the","fields","specified","in","the","*","_NEEDED","[","]","lists",".","Example","--","--","--","-",">",">",">","from","speechbrain.inference.ASR","import","EncoderASR",">",">",">","tmpdir","=","getfixture","(","``","tmpdir","''",")",">",">",">","asr_model","=","EncoderASR.from_hparams","(","...","source=","''","speechbrain\/asr-wav2vec2-commonvoice-fr","''",",","...","savedir=tmpdir",",","...",")","#","doctest",":","+SKIP",">",">",">","asr_model.transcribe_file","(","``","samples\/audio_samples\/example_fr.wav","''",")","#","doctest",":","+SKIP"]
docstr: Set the decoding function based on the parameters defined in the hyperparameter file.
docstr_tok: ["Set","the","decoding","function","based","on","the","parameters","defined","in","the","hyperparameter","file","."]
code: def set_decoding_function(self):
      """Set the decoding function based on the parameters defined in the hyperparameter file."""
      if self.decoding_type == "beam":
          if hasattr(self.hparams, "kenlm_model_path"):
              source, fl = split_path(self.hparams.kenlm_model_path)
              kenlm_model_path = str(
                  fetch(fl, source=source, savedir=".")
              )
              self.hparams.test_beam_search[
                  "kenlm_model_path"
              ] = kenlm_model_path
  
          vocab_list = [
              self.tokenizer.id_to_piece(i)
              for i in range(self.tokenizer.vocab_size())
          ]
  
          from speechbrain.decoders.ctc import CTCBeamSearcher
  
          self.decoding_function = CTCBeamSearcher(
              **self.hparams.test_beam_search, vocab_list=vocab_list
          )
      else:
          from functools import partial
  
          self.decoding_function = partial(
              speechbrain.decoders.ctc_greedy_decode,
              blank_id=self.hparams.blank_index,
          )
  
imports: import torch
  import sentencepiece
  import speechbrain
  from speechbrain.inference.interfaces import Pretrained
  from speechbrain.utils.fetching import fetch
  from speechbrain.utils.data_utils import split_path
label_desc: Use image node_id 2 for calling the EncoderASR obj's underlying member method code with example usage: obj.set_decoding_function() without return types