code: def recognize_legacy(
      recognizer,
      audio_data: AudioData,
      key: str | None = None,
      language: str = "en-US",
      pfilter: ProfanityFilterLevel = 0,
      show_all: bool = False,
      with_confidence: bool = False,
  ):
      """
      Performs speech recognition on ``audio_data`` (an ``AudioData`` instance), using the Google Speech Recognition API.
  
      The Google Speech Recognition API key is specified by ``key``. If not specified, it uses a generic key that works out of the box. This should generally be used for personal or testing purposes only, as it **may be revoked by Google at any time**.
  
      To obtain your own API key, simply following the steps on the `API Keys <http://www.chromium.org/developers/how-tos/api-keys>`__ page at the Chromium Developers site. In the Google Developers Console, Google Speech Recognition is listed as "Speech API".
  
      The recognition language is determined by ``language``, an RFC5646 language tag like ``"en-US"`` (US English) or ``"fr-FR"`` (International French), defaulting to US English. A list of supported language tags can be found in this `StackOverflow answer <http://stackoverflow.com/a/14302134>`__.
  
      The profanity filter level can be adjusted with ``pfilter``: 0 - No filter, 1 - Only shows the first character and replaces the rest with asterisks. The default is level 0.
  
      Returns the most likely transcription if ``show_all`` is false (the default). Otherwise, returns the raw API response as a JSON dictionary.
  
      Raises a ``speech_recognition.UnknownValueError`` exception if the speech is unintelligible. Raises a ``speech_recognition.RequestError`` exception if the speech recognition operation failed, if the key isn't valid, or if there is no internet connection.
      """
      request_builder = create_request_builder(
          key=key, language=language, filter_level=pfilter
      )
      request = request_builder.build(audio_data)
  
      response_text = obtain_transcription(
          request, timeout=recognizer.operation_timeout
      )
  
      output_parser = OutputParser(
          show_all=show_all, with_confidence=with_confidence
      )
      return output_parser.parse(response_text)
  
imports: from __future__ import annotations
  import json
  from typing import Dict, Literal, TypedDict
  from urllib.error import HTTPError, URLError
  from urllib.parse import urlencode
  from urllib.request import Request, urlopen
  from typing_extensions import NotRequired
  from speech_recognition.audio import AudioData
  from speech_recognition.exceptions import RequestError, UnknownValueError
label_desc: Use image node_id 3 for calling a global function with example usage: recognize_legacy(recognizer, audio_data, key, language, pfilter, show_all, with_confidence) and returns: output_parser