[Whisper] Add `large-v3` version support
Author: flyingleafe
Pull request: yes

# What does this PR do?

Adds the ability to download and convert the fresh `large-v3` version of Whisper (https://github.com/openai/whisper/pull/1761/files).
Closes #27331.

The usage of `_download` method in `convert_openai_to_hf.py` turned out to be broken, that was fixed.
I also plan to add the processor (feature extractor + tokenizer) automatic file export today and take care that subtle changes in language tag tokenization are supported - hence the draft status.


<!--
Congratulations! You've made it this far! You're not quite done yet though.

Once merged, your PR is going to appear in the release notes with the title you set, so make sure it's a great title that fully reflects the extent of your awesome contribution.

Then, please replace this with a description of the change and which issue is fixed (if applicable). Please also include relevant motivation and context. List any dependencies (if any) that are required for this change.

Once you're done, someone will review your PR shortly (see the section "Who can review?" below to tag some potential reviewers). They may suggest changes to make the code even better. If no one reviewed your PR after a week has passed, don't hesitate to post a new comment @-mentioning the same persons---sometimes notifications get lost.
-->


## Before submitting
- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [x] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#start-contributing-pull-requests),
      Pull Request section?
- [x] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link
      to it if that's the case.
- [x] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [ ] Did you write any new necessary tests?


## Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

<!-- Your PR will be replied to more quickly if you can figure out the right person to tag with @

 If you know how to use git blame, that is the easiest way, otherwise, here is a rough guide of **who to tag**.
 Please tag fewer than 3 people.

Models:

- text models: @ArthurZucker and @younesbelkada
- vision models: @amyeroberts
- speech models: @sanchit-gandhi
- graph models: @clefourrier

Library:

- flax: @sanchit-gandhi
- generate: @gante
- pipelines: @Narsil
- tensorflow: @gante and @Rocketknight1
- tokenizers: @ArthurZucker
- trainer: @muellerzr and @pacman100

Integrations:

- deepspeed: HF Trainer/Accelerate: @pacman100
- ray/raytune: @richardliaw, @amogkam
- Big Model Inference: @SunMarc
- quantization (bitsandbytes, autogpt): @SunMarc and @younesbelkada

Documentation: @stevhliu and @MKhalusova

HF projects:

- accelerate: [different repo](https://github.com/huggingface/accelerate)
- datasets: [different repo](https://github.com/huggingface/datasets)
- diffusers: [different repo](https://github.com/huggingface/diffusers)
- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)

Maintained examples (not research project or legacy):

- Flax: @sanchit-gandhi
- PyTorch: See Models above and tag the person corresponding to the modality of the example.
- TensorFlow: @Rocketknight1

 -->


Comments:
Thanks, this can be extremely helpful!

@ArthurZucker Thanks! Did not see the download fixing PR, and you were quite fast with tokenizer support, congrats)
Except for the tokenizer, the feature extractor parameters should also be fetched and exported, esp. given that `v3` uses a different number of melbanks. I can handle that in this PR, if you do not yet have it already implemented somewhere locally.

Yes for sure! 

@ArthurZucker Added feature extractor export.
I reused the pre-computed mel filters from `openai/whisper` repository, doing so required slight changes in `WhisperFeatureExtractor` logic. I anticipate that auto-computed filters should be equivalent to ones saved in `openai/whisper`, but I am not 100% sure, so I think this is a more reliable way to obtain 100% functional equivalence.

Nice, just merged #27338 can you rebase? 

@ArthurZucker merged, can instead rebase/forcepush if that's preferable.

Merging should be fine, reviewing now ! 

@ArthurZucker removed everything related to downloading the pre-computed filters, they are indeed equivalent to the constructed ones (`np.allclose == True`). 

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_27336). All of your documentation changes will be reflected on that endpoint.

@ArthurZucker @sanchit-gandhi Your comment for the full preprocessor export is addressed. Since the preprocessor has the tokenizer as its constituent part, I renamed the `--convert_tokenizer` option to `--convert_preprocessor`.

I also took the liberty of removing additional parameters of `--whisper_version` and `--multilingual`, since the actual number of supported languages is [derivable from the vocabulary size](https://github.com/openai/whisper/blob/fcfeaf1b61994c071bba62da47d7846933576ac9/whisper/model.py#L271), which is the part of OpenAI model checkpoint.

@sanchit-gandhi I implemented the fetching of generation config from HF based on the number of languages supported  as you have suggested, but it is kind of a chicken-and-egg situation. The alignment heads can be hardcoded into the dictionary [as OpenAI does that](https://github.com/openai/whisper/blob/fcfeaf1b61994c071bba62da47d7846933576ac9/whisper/__init__.py#L34), and the other parameters are either derived from the tokenizer or hardcoded as well. The only setting I don't quite understand how to derive is the set of suppressed tokens, if you give me a hint on that, I can remove the dependency on downloading extra stuff from HF completely.

@sanchit-gandhi 
Basically what I did is setting the alignment head appropriately if the user provided Whisper model version instead of a local checkpoint, and not setting them (with a warning) otherwise.
It could be possible to also detect if the local checkpoint is equivalent to the official one by checking the hash, but that is probably a non-issue, I cannot think of a genuine use case when the user has the OpenAI checkpoint saved locally but is unable/unwilling to simply re-download it.

@sanchit-gandhi Your point is valid - why do extra work if we are downloading generation configs from HF hub anyway.
Removed all logic related to that, simply preserving the alignment heads in the config if the original checkpoint is downloaded.

@sanchit-gandhi People [complain](https://github.com/guillaumekln/faster-whisper/pull/548#issuecomment-1807779706) in the downstream community projects that they expect tokenizer files in fast format (`tokenizer.json`) to be also present in the HF checkpoint.

I added a couple of lines here for conversion and export of fast tokenizer as well. Only you and your colleagues can add that to the official checkpoint though.

@sanchit-gandhi bump, is that good for merge?

@sanchit-gandhi Your last suggestion has been done three days ago, let's merge if good to go

Thanks for bearing with both of us 😉