class_docstr: Pipeline that aims at extracting spoken text contained within some audio.
  
  The input can be either a raw waveform or a audio file. In case of the audio file, ffmpeg should be installed for
  to support multiple audio formats
  
  Example:
  
  ```python
  >>> from transformers import pipeline
  
  >>> transcriber = pipeline(model="openai/whisper-base")
  >>> transcriber("https://huggingface.co/datasets/Narsil/asr_dummy/resolve/main/1.flac")
  {'text': ' He hoped there would be stew for dinner, turnips and carrots and bruised potatoes and fat mutton pieces to be ladled out in thick, peppered flour-fatten sauce.'}
  ```
  
  Learn more about the basics of using a pipeline in the [pipeline tutorial](../pipeline_tutorial)
  
  Arguments:
      model ([`PreTrainedModel`] or [`TFPreTrainedModel`]):
          The model that will be used by the pipeline to make predictions. This needs to be a model inheriting from
          [`PreTrainedModel`] for PyTorch and [`TFPreTrainedModel`] for TensorFlow.
      tokenizer ([`PreTrainedTokenizer`]):
          The tokenizer that will be used by the pipeline to encode data for the model. This object inherits from
          [`PreTrainedTokenizer`].
      feature_extractor ([`SequenceFeatureExtractor`]):
          The feature extractor that will be used by the pipeline to encode waveform for the model.
      chunk_length_s (`float`, *optional*, defaults to 0):
          The input length for in each chunk. If `chunk_length_s = 0` then chunking is disabled (default).
  
          <Tip>
  
          For more information on how to effectively use `chunk_length_s`, please have a look at the [ASR chunking
          blog post](https://huggingface.co/blog/asr-chunking).
  
          </Tip>
  
      stride_length_s (`float`, *optional*, defaults to `chunk_length_s / 6`):
          The length of stride on the left and right of each chunk. Used only with `chunk_length_s > 0`. This enables
          the model to *see* more context and infer letters better than without this context but the pipeline
          discards the stride bits at the end to make the final reconstitution as perfect as possible.
  
          <Tip>
  
          For more information on how to effectively use `stride_length_s`, please have a look at the [ASR chunking
          blog post](https://huggingface.co/blog/asr-chunking).
  
          </Tip>
  
      framework (`str`, *optional*):
          The framework to use, either `"pt"` for PyTorch or `"tf"` for TensorFlow. The specified framework must be
          installed. If no framework is specified, will default to the one currently installed. If no framework is
          specified and both frameworks are installed, will default to the framework of the `model`, or to PyTorch if
          no model is provided.
      device (Union[`int`, `torch.device`], *optional*):
          Device ordinal for CPU/GPU supports. Setting this to `None` will leverage CPU, a positive will run the
          model on the associated CUDA device id.
      decoder (`pyctcdecode.BeamSearchDecoderCTC`, *optional*):
          [PyCTCDecode's
          BeamSearchDecoderCTC](https://github.com/kensho-technologies/pyctcdecode/blob/2fd33dc37c4111417e08d89ccd23d28e9b308d19/pyctcdecode/decoder.py#L180)
          can be passed for language model boosted decoding. See [`Wav2Vec2ProcessorWithLM`] for more information.
class_docstr_tok: ["Pipeline","that","aims","at","extracting","spoken","text","contained","within","some","audio",".","The","input","can","be","either","a","raw","waveform","or","a","audio","file",".","In","case","of","the","audio","file",",","ffmpeg","should","be","installed","for","to","support","multiple","audio","formats","Example",":","``","`","python",">",">",">","from","transformers","import","pipeline",">",">",">","transcriber","=","pipeline","(","model=","''","openai\/whisper-base","''",")",">",">",">","transcriber","(","``","https",":","\/\/huggingface.co\/datasets\/Narsil\/asr_dummy\/resolve\/main\/1.flac","''",")","{","'text","'",":","'","He","hoped","there","would","be","stew","for","dinner",",","turnips","and","carrots","and","bruised","potatoes","and","fat","mutton","pieces","to","be","ladled","out","in","thick",",","peppered","flour-fatten","sauce",".","'","}","``","`","Learn","more","about","the","basics","of","using","a","pipeline","in","the","[","pipeline","tutorial","]","(","..","\/pipeline_tutorial",")","Arguments",":","model","(","[","`","PreTrainedModel","`","]","or","[","`","TFPreTrainedModel","`","]",")",":","The","model","that","will","be","used","by","the","pipeline","to","make","predictions",".","This","needs","to","be","a","model","inheriting","from","[","`","PreTrainedModel","`","]","for","PyTorch","and","[","`","TFPreTrainedModel","`","]","for","TensorFlow",".","tokenizer","(","[","`","PreTrainedTokenizer","`","]",")",":","The","tokenizer","that","will","be","used","by","the","pipeline","to","encode","data","for","the","model",".","This","object","inherits","from","[","`","PreTrainedTokenizer","`","]",".","feature_extractor","(","[","`","SequenceFeatureExtractor","`","]",")",":","The","feature","extractor","that","will","be","used","by","the","pipeline","to","encode","waveform","for","the","model",".","chunk_length_s","(","`","float","`",",","*","optional","*",",","defaults","to","0",")",":","The","input","length","for","in","each","chunk",".","If","`","chunk_length_s","=","0","`","then","chunking","is","disabled","(","default",")",".","<","Tip",">","For","more","information","on","how","to","effectively","use","`","chunk_length_s","`",",","please","have","a","look","at","the","[","ASR","chunking","blog","post","]","(","https",":","\/\/huggingface.co\/blog\/asr-chunking",")",".","<","\/Tip",">","stride_length_s","(","`","float","`",",","*","optional","*",",","defaults","to","`","chunk_length_s","\/","6","`",")",":","The","length","of","stride","on","the","left","and","right","of","each","chunk",".","Used","only","with","`","chunk_length_s",">","0","`",".","This","enables","the","model","to","*","see","*","more","context","and","infer","letters","better","than","without","this","context","but","the","pipeline","discards","the","stride","bits","at","the","end","to","make","the","final","reconstitution","as","perfect","as","possible",".","<","Tip",">","For","more","information","on","how","to","effectively","use","`","stride_length_s","`",",","please","have","a","look","at","the","[","ASR","chunking","blog","post","]","(","https",":","\/\/huggingface.co\/blog\/asr-chunking",")",".","<","\/Tip",">","framework","(","`","str","`",",","*","optional","*",")",":","The","framework","to","use",",","either","`","``","pt","''","`","for","PyTorch","or","`","``","tf","''","`","for","TensorFlow",".","The","specified","framework","must","be","installed",".","If","no","framework","is","specified",",","will","default","to","the","one","currently","installed",".","If","no","framework","is","specified","and","both","frameworks","are","installed",",","will","default","to","the","framework","of","the","`","model","`",",","or","to","PyTorch","if","no","model","is","provided",".","device","(","Union","[","`","int","`",",","`","torch.device","`","]",",","*","optional","*",")",":","Device","ordinal","for","CPU\/GPU","supports",".","Setting","this","to","`","None","`","will","leverage","CPU",",","a","positive","will","run","the","model","on","the","associated","CUDA","device","id",".","decoder","(","`","pyctcdecode.BeamSearchDecoderCTC","`",",","*","optional","*",")",":","[","PyCTCDecode's","BeamSearchDecoderCTC","]","(","https",":","\/\/github.com\/kensho-technologies\/pyctcdecode\/blob\/2fd33dc37c4111417e08d89ccd23d28e9b308d19\/pyctcdecode\/decoder.py","#","L180",")","can","be","passed","for","language","model","boosted","decoding",".","See","[","`","Wav2Vec2ProcessorWithLM","`","]","for","more","information","."]
code: def __init__(
      self,
      model: "PreTrainedModel",
      feature_extractor: Union["SequenceFeatureExtractor", str] = None,
      tokenizer: Optional[PreTrainedTokenizer] = None,
      decoder: Optional[Union["BeamSearchDecoderCTC", str]] = None,
      modelcard: Optional[ModelCard] = None,
      framework: Optional[str] = None,
      task: str = "",
      args_parser: ArgumentHandler = None,
      device: Union[int, "torch.device"] = None,
      torch_dtype: Optional[Union[str, "torch.dtype"]] = None,
      binary_output: bool = False,
      **kwargs,
  ):
      if framework is None:
          framework, model = infer_framework_load_model(
              model, config=model.config
          )
  
      self.task = task
      self.model = model
      self.tokenizer = tokenizer
      self.feature_extractor = feature_extractor
      self.modelcard = modelcard
      self.framework = framework
  
      # `accelerate` device map
      hf_device_map = getattr(self.model, "hf_device_map", None)
  
      if hf_device_map is not None and device is not None:
          raise ValueError(
              "The model has been loaded with `accelerate` and therefore cannot be moved to a specific device. Please "
              "discard the `device` argument when creating your pipeline object."
          )
  
      if self.framework == "tf":
          raise ValueError(
              "The AutomaticSpeechRecognitionPipeline is only available in PyTorch."
          )
  
      # We shouldn't call `model.to()` for models loaded with accelerate
      if device is not None and not (
          isinstance(device, int) and device < 0
      ):
          self.model.to(device)
  
      if device is None:
          if hf_device_map is not None:
              # Take the first device used by `accelerate`.
              device = next(iter(hf_device_map.values()))
          else:
              device = -1
  
      if is_torch_available() and self.framework == "pt":
          if isinstance(device, torch.device):
              self.device = device
          elif isinstance(device, str):
              self.device = torch.device(device)
          elif device < 0:
              self.device = torch.device("cpu")
          else:
              self.device = torch.device(f"cuda:{device}")
      else:
          self.device = device if device is not None else -1
      self.torch_dtype = torch_dtype
      self.binary_output = binary_output
  
      # Update config and generation_config with task specific parameters
      task_specific_params = self.model.config.task_specific_params
      if (
          task_specific_params is not None
          and task in task_specific_params
      ):
          self.model.config.update(task_specific_params.get(task))
          if self.model.can_generate():
              self.model.generation_config.update(
                  **task_specific_params.get(task)
              )
  
      self.call_count = 0
      self._batch_size = kwargs.pop("batch_size", None)
      self._num_workers = kwargs.pop("num_workers", None)
  
      # set the model type so we can check we have the right pre- and post-processing parameters
      if self.model.config.model_type == "whisper":
          self.type = "seq2seq_whisper"
      elif (
          self.model.__class__.__name__
          in MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES.values()
      ):
          self.type = "seq2seq"
      elif (
          feature_extractor._processor_class
          and feature_extractor._processor_class.endswith("WithLM")
          and decoder is not None
      ):
          self.decoder = decoder
          self.type = "ctc_with_lm"
      else:
          self.type = "ctc"
  
      (
          self._preprocess_params,
          self._forward_params,
          self._postprocess_params,
      ) = self._sanitize_parameters(**kwargs)
  
      mapping = MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES.copy()
      mapping.update(MODEL_FOR_CTC_MAPPING_NAMES)
      self.check_model_type(mapping)
  
imports: from collections import defaultdict
  from typing import TYPE_CHECKING, Dict, Optional, Union
  import numpy
  import requests
  from ..modelcard import ModelCard
  from ..tokenization_utils import PreTrainedTokenizer
  from ..utils import is_torch_available, is_torchaudio_available, logging
  from .audio_utils import ffmpeg_read
  from .base import ArgumentHandler, ChunkPipeline, infer_framework_load_model
label_desc: Use image node_id 1 to create a new AutomaticSpeechRecognitionPipeline object from inherited base classes: ChunkPipeline with example: obj = AutomaticSpeechRecognitionPipeline(model, feature_extractor, tokenizer, decoder, modelcard, framework, task, args_parser, device, torch_dtype, binary_output)