Support for BeamSearchEncoderDecoderOutput in AutomaticSpeechRecognitionPipeline‎ 
Author: pli66
Pull request: no

### Feature request

The ASR pipeline does not support the return_dict_in_generate function, which returns a [BeamSearchEncoderDecoderOutput ](https://huggingface.co/docs/transformers/internal/generation_utils#transformers.generation.BeamSearchEncoderDecoderOutput). Using return_dict_in_generate is possible without the pipeline, but here is what happens when we try to use with pipeline:

```
from transformers import pipeline

url = "https://github.com/pli66/test/raw/main/personage_hardy_ah_64kbTrimmed0.mp3"

pipe = pipeline(task="automatic-speech-recognition", model="openai/whisper-medium")
print(pipe(url, return_timestamps=True, generate_kwargs={"return_dict_in_generate":True}))
```
```
AttributeError                            Traceback (most recent call last)
Cell In[7], line 7
      5 pipe = pipeline(task="automatic-speech-recognition", model="openai/whisper-medium")
      6 # print(pipe(url, return_timestamps=True, return_dict_in_generate=True))
----> 7 print(pipe(url, return_timestamps=True, generate_kwargs={"return_dict_in_generate":True}))

File ~/.conda/envs/voice/lib/python3.11/site-packages/transformers/pipelines/automatic_speech_recognition.py:272, in AutomaticSpeechRecognitionPipeline.__call__(self, inputs, **kwargs)
    225 def __call__(
    226     self,
    227     inputs: Union[np.ndarray, bytes, str],
    228     **kwargs,
    229 ):
    230     """
    231     Transcribe the audio sequence(s) given as inputs to text. See the [`AutomaticSpeechRecognitionPipeline`]
    232     documentation for more information.
   (...)
    270                     `"".join(chunk["text"] for chunk in output["chunks"])`.
    271     """
--> 272     return super().__call__(inputs, **kwargs)

File ~/.conda/envs/voice/lib/python3.11/site-packages/transformers/pipelines/base.py:1114, in Pipeline.__call__(self, inputs, num_workers, batch_size, *args, **kwargs)
   1112     return self.iterate(inputs, preprocess_params, forward_params, postprocess_params)
   1113 elif self.framework == "pt" and isinstance(self, ChunkPipeline):
-> 1114     return next(
   1115         iter(
   1116             self.get_iterator(
   1117                 [inputs], num_workers, batch_size, preprocess_params, forward_params, postprocess_params
   1118             )
   1119         )
   1120     )
   1121 else:
   1122     return self.run_single(inputs, preprocess_params, forward_params, postprocess_params)

File ~/.conda/envs/voice/lib/python3.11/site-packages/transformers/pipelines/pt_utils.py:125, in PipelineIterator.__next__(self)
    123 # We're out of items within a batch
    124 item = next(self.iterator)
--> 125 processed = self.infer(item, **self.params)
    126 # We now have a batch of "inferred things".
    127 if self.loader_batch_size is not None:
    128     # Try to infer the size of the batch

File ~/.conda/envs/voice/lib/python3.11/site-packages/transformers/pipelines/automatic_speech_recognition.py:512, in AutomaticSpeechRecognitionPipeline.postprocess(self, model_outputs, decoder_kwargs, return_timestamps, return_language)
    510 stride = None
    511 for outputs in model_outputs:
--> 512     items = outputs[key].numpy()
    513     stride = outputs.get("stride", None)
    514     if stride is not None and self.type in {"ctc", "ctc_with_lm"}:

AttributeError: 'ModelOutput' object has no attribute 'numpy'
```

I would like to be able to see all the outputs of BeamSearchEncoderDecoderOutput passed through the pipeline

### Motivation

I could use the non-pipeline way, but https://github.com/huggingface/transformers/issues/24959 is solved by the use of pipeline. Therefore I need a solution that solves both that issue and can provide the output from return_dict_in_generate which I use with output_scores to obtain probabilities that I need.

### Your contribution

I can start working on a PR for this, but would like to hear @sanchit-gandhi 's thoughts on this. Would this be in accordance with the philosophy of pipeline?

Comments:
cc @sanchit-gandhi 

Hey @pli66 - thanks for opening this issue. From reading through, I think this is a more general `pipeline` discussion, where the question is:

_Can we return the outputs of `.generate` using the `pipeline` method?_

Here, I think we can refactor the ASR pipeline a bit to achieve this, but whether or not this complies with the `pipeline` philosophy, I'd like to refer onto @Narsil to lend his view

General guideline: Pipeline are meant to be simple to use tools for non ML developpers, not something that supports every feature, dropping down to lower level for more advanced/detailed usage is expected.

Why is `return_dict_in_generate` interesting here for you ?

I use it with output_scores to get the probabilities

So in short, any end-to-end mapping of `speech input -> text output` falls under the paradigm of the pipeline, but more granular than this (e.g `speech input -> log probs -> text output`) we need to use the model + processor

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.

Hey @pli66 - did the last comment answer your question? Happy to clarify any of the above points!

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.