code: def main():
      parser = argparse.ArgumentParser()
  
      parser.add_argument(
          "--access_key",
          help="AccessKey obtained from Picovoice Console (https://console.picovoice.ai/)",
          required=True,
      )
  
      parser.add_argument(
          "--wav_path",
          help="Absolute path to input .wav file",
          required=True,
      )
  
      parser.add_argument(
          "--keywords",
          nargs="+",
          help="List of default keywords for detection. "
          "Available keywords: %s"
          % ", ".join("%s" % w for w in sorted(pvporcupine.KEYWORDS)),
          choices=sorted(list(pvporcupine.KEYWORDS)),
          metavar="",
      )
  
      parser.add_argument(
          "--keyword_paths",
          nargs="+",
          help="Absolute paths to keyword model files. If not set it will be populated from `--keywords` argument",
      )
  
      parser.add_argument(
          "--library_path",
          help="Absolute path to dynamic library. Default: using the library provided by `pvporcupine`",
      )
  
      parser.add_argument(
          "--model_path",
          help="Absolute path to the file containing model parameters. "
          "Default: using the library provided by `pvporcupine`",
      )
  
      parser.add_argument(
          "--sensitivities",
          nargs="+",
          help="Sensitivities for detecting keywords. Each value should be a number within [0, 1]. A higher "
          "sensitivity results in fewer misses at the cost of increasing the false alarm rate. If not set 0.5 "
          "will be used.",
          type=float,
          default=None,
      )
  
      args = parser.parse_args()
  
      if args.keyword_paths is None:
          if args.keywords is None:
              raise ValueError(
                  "Either `--keywords` or `--keyword_paths` must be set."
              )
  
          keyword_paths = [
              pvporcupine.KEYWORD_PATHS[x] for x in args.keywords
          ]
      else:
          keyword_paths = args.keyword_paths
  
      if args.sensitivities is None:
          args.sensitivities = [0.5] * len(keyword_paths)
  
      if len(keyword_paths) != len(args.sensitivities):
          raise ValueError(
              "Number of keywords does not match the number of sensitivities."
          )
  
      try:
          porcupine = pvporcupine.create(
              access_key=args.access_key,
              library_path=args.library_path,
              model_path=args.model_path,
              keyword_paths=keyword_paths,
              sensitivities=args.sensitivities,
          )
      except pvporcupine.PorcupineInvalidArgumentError as e:
          print(
              "One or more arguments provided to Porcupine is invalid: ",
              args,
          )
          print(e)
          raise e
      except pvporcupine.PorcupineActivationError as e:
          print("AccessKey activation error")
          raise e
      except pvporcupine.PorcupineActivationLimitError as e:
          print(
              "AccessKey '%s' has reached it's temporary device limit"
              % args.access_key
          )
          raise e
      except pvporcupine.PorcupineActivationRefusedError as e:
          print("AccessKey '%s' refused" % args.access_key)
          raise e
      except pvporcupine.PorcupineActivationThrottledError as e:
          print("AccessKey '%s' has been throttled" % args.access_key)
          raise e
      except pvporcupine.PorcupineError as e:
          print("Failed to initialize Porcupine")
          raise e
  
      audio = read_file(args.wav_path, porcupine.sample_rate)
  
      keywords = list()
      for x in keyword_paths:
          keyword_phrase_part = (
              os.path.basename(x).replace(".ppn", "").split("_")
          )
          if len(keyword_phrase_part) > 6:
              keywords.append(" ".join(keyword_phrase_part[0:-6]))
          else:
              keywords.append(keyword_phrase_part[0])
  
      num_frames = len(audio) // porcupine.frame_length
      for i in range(num_frames):
          frame = audio[
              i
              * porcupine.frame_length : (i + 1)
              * porcupine.frame_length
          ]
          result = porcupine.process(frame)
          if result >= 0:
              print(
                  "Detected '%s' at %.2f sec"
                  % (
                      keywords[result],
                      float(i * porcupine.frame_length)
                      / float(porcupine.sample_rate),
                  )
              )
  
      porcupine.delete()
  
imports: import argparse
  import os
  import struct
  import wave
  import pvporcupine
label_desc: Use image node_id 2 for calling a global function with example usage: main() without return types