code: def main():
      parser = argparse.ArgumentParser(
          description="Running DeepSpeech inference."
      )
      parser.add_argument(
          "--model",
          required=True,
          help="Path to the model (protocol buffer binary file)",
      )
      parser.add_argument(
          "--scorer",
          required=False,
          help="Path to the external scorer file",
      )
      parser.add_argument(
          "--audio",
          required=True,
          help="Path to the audio file to run (WAV format)",
      )
      parser.add_argument(
          "--beam_width",
          type=int,
          help="Beam width for the CTC decoder",
      )
      parser.add_argument(
          "--lm_alpha",
          type=float,
          help="Language model weight (lm_alpha). If not specified, use default from the scorer package.",
      )
      parser.add_argument(
          "--lm_beta",
          type=float,
          help="Word insertion bonus (lm_beta). If not specified, use default from the scorer package.",
      )
      parser.add_argument(
          "--version",
          action=VersionAction,
          help="Print version and exits",
      )
      parser.add_argument(
          "--extended",
          required=False,
          action="store_true",
          help="Output string from extended metadata",
      )
      parser.add_argument(
          "--json",
          required=False,
          action="store_true",
          help="Output json from metadata with timestamp of each word",
      )
      parser.add_argument(
          "--candidate_transcripts",
          type=int,
          default=3,
          help="Number of candidate transcripts to include in JSON output",
      )
      parser.add_argument(
          "--hot_words", type=str, help="Hot-words and their boosts."
      )
      args = parser.parse_args()
  
      print(
          "Loading model from file {}".format(args.model),
          file=sys.stderr,
      )
      model_load_start = timer()
      # sphinx-doc: python_ref_model_start
      ds = Model(args.model)
      # sphinx-doc: python_ref_model_stop
      model_load_end = timer() - model_load_start
      print(
          "Loaded model in {:.3}s.".format(model_load_end),
          file=sys.stderr,
      )
  
      if args.beam_width:
          ds.setBeamWidth(args.beam_width)
  
      desired_sample_rate = ds.sampleRate()
  
      if args.scorer:
          print(
              "Loading scorer from files {}".format(args.scorer),
              file=sys.stderr,
          )
          scorer_load_start = timer()
          ds.enableExternalScorer(args.scorer)
          scorer_load_end = timer() - scorer_load_start
          print(
              "Loaded scorer in {:.3}s.".format(scorer_load_end),
              file=sys.stderr,
          )
  
          if args.lm_alpha and args.lm_beta:
              ds.setScorerAlphaBeta(args.lm_alpha, args.lm_beta)
  
      if args.hot_words:
          print("Adding hot-words", file=sys.stderr)
          for word_boost in args.hot_words.split(","):
              word, boost = word_boost.split(":")
              ds.addHotWord(word, float(boost))
  
      fin = wave.open(args.audio, "rb")
      fs_orig = fin.getframerate()
      if fs_orig != desired_sample_rate:
          print(
              "Warning: original sample rate ({}) is different than {}hz. Resampling might produce erratic speech recognition.".format(
                  fs_orig, desired_sample_rate
              ),
              file=sys.stderr,
          )
          fs_new, audio = convert_samplerate(
              args.audio, desired_sample_rate
          )
      else:
          audio = np.frombuffer(
              fin.readframes(fin.getnframes()), np.int16
          )
  
      audio_length = fin.getnframes() * (1 / fs_orig)
      fin.close()
  
      print("Running inference.", file=sys.stderr)
      inference_start = timer()
      # sphinx-doc: python_ref_inference_start
      if args.extended:
          print(
              metadata_to_string(
                  ds.sttWithMetadata(audio, 1).transcripts[0]
              )
          )
      elif args.json:
          print(
              metadata_json_output(
                  ds.sttWithMetadata(audio, args.candidate_transcripts)
              )
          )
      else:
          print(ds.stt(audio))
      # sphinx-doc: python_ref_inference_stop
      inference_end = timer() - inference_start
      print(
          "Inference took %0.3fs for %0.3fs audio file."
          % (inference_end, audio_length),
          file=sys.stderr,
      )
  
file_path: DeepSpeech/native_client/python/client.py
imports: from __future__ import absolute_import, division, print_function
  import argparse
  import numpy
  import shlex
  import subprocess
  import sys
  import wave
  import json
  from deepspeech import Model, version
  from timeit import default_timer
label_desc: Use image node_id 5 for calling a global function with example usage: main() without return types