Repository navigation
docs: update speech recognition examples #41027
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
eustlb
merged 11 commits into
huggingface:main
from
tayo4christ:fix/whisper-example-no-dataset-scripts
Sep 30, 2025
Merged
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
2735c3e
examples(speech): load Common Voice from Hub; remove deprecated datas…
tayo4christ 24902d8
docs/examples(speech): pin CTC streaming & other CTC commands to Hub …
tayo4christ 9b561eb
make style
eustlb 5664ade
examples(speech): align DataTrainingArguments help with datasets docs…
tayo4christ 1f1fd79
docs/examples(speech): address review remove Hub subsection & Whispe…
tayo4christ 3935670
style: apply ruff/black/usort/codespell on examples/speech-recognition
tayo4christ b876537
Merge branch 'main' into fix/whisper-example-no-dataset-scripts
eustlb 39445b7
Apply style fixes
github-actions[bot] 5794d8a
Update examples/pytorch/speech-recognition/README.md
eustlb 2b5d9ca
update doc to match load_dataset
eustlb aa8082a
fix
eustlb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,7 +63,10 @@ | |
| # Will error if the minimal version of Transformers is not installed. Remove at your own risks. | ||
| check_min_version("4.57.0.dev0") | ||
|
|
||
| require_version("datasets>=1.18.0", "To fix: pip install -r examples/pytorch/speech-recognition/requirements.txt") | ||
| require_version( | ||
| "datasets>=1.18.0", | ||
| "To fix: pip install -r examples/pytorch/speech-recognition/requirements.txt", | ||
| ) | ||
|
|
||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
@@ -91,13 +94,16 @@ class ModelArguments: | |
| metadata={"help": "Where do you want to store the pretrained models downloaded from huggingface.co"}, | ||
| ) | ||
| freeze_feature_encoder: bool = field( | ||
| default=True, metadata={"help": "Whether to freeze the feature encoder layers of the model."} | ||
| default=True, | ||
| metadata={"help": "Whether to freeze the feature encoder layers of the model."}, | ||
| ) | ||
| attention_dropout: float = field( | ||
| default=0.0, metadata={"help": "The dropout ratio for the attention probabilities."} | ||
| default=0.0, | ||
| metadata={"help": "The dropout ratio for the attention probabilities."}, | ||
| ) | ||
| activation_dropout: float = field( | ||
| default=0.0, metadata={"help": "The dropout ratio for activations inside the fully connected layer."} | ||
| default=0.0, | ||
| metadata={"help": "The dropout ratio for activations inside the fully connected layer."}, | ||
| ) | ||
| feat_proj_dropout: float = field(default=0.0, metadata={"help": "The dropout ratio for the projected features."}) | ||
| hidden_dropout: float = field( | ||
|
|
@@ -140,7 +146,8 @@ class ModelArguments: | |
| ) | ||
| layerdrop: float = field(default=0.0, metadata={"help": "The LayerDrop probability."}) | ||
| ctc_loss_reduction: Optional[str] = field( | ||
| default="mean", metadata={"help": "The way the ctc loss should be reduced. Should be one of 'mean' or 'sum'."} | ||
| default="mean", | ||
| metadata={"help": "The way the ctc loss should be reduced. Should be one of 'mean' or 'sum'."}, | ||
| ) | ||
| ctc_zero_infinity: Optional[bool] = field( | ||
| default=False, | ||
|
|
@@ -172,7 +179,8 @@ class DataTrainingArguments: | |
| metadata={"help": "The configuration name of the dataset to use (via the datasets library)."} | ||
| ) | ||
|
tayo4christ marked this conversation as resolved.
Resolved
|
||
| dataset_config_name: str = field( | ||
| default=None, metadata={"help": "The configuration name of the dataset to use (via the datasets library)."} | ||
| default=None, | ||
| metadata={"help": "The configuration name of the dataset to use (via the datasets library)."}, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment about this has not been addressed!
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. addressed it myself |
||
| ) | ||
| train_split_name: str = field( | ||
| default="train+validation", | ||
|
|
@@ -198,7 +206,8 @@ class DataTrainingArguments: | |
| metadata={"help": "The name of the dataset column containing the text data. Defaults to 'text'"}, | ||
| ) | ||
| overwrite_cache: bool = field( | ||
| default=False, metadata={"help": "Overwrite the cached preprocessed datasets or not."} | ||
| default=False, | ||
| metadata={"help": "Overwrite the cached preprocessed datasets or not."}, | ||
| ) | ||
| preprocessing_num_workers: Optional[int] = field( | ||
| default=None, | ||
|
|
@@ -240,7 +249,8 @@ class DataTrainingArguments: | |
| }, | ||
| ) | ||
| min_duration_in_seconds: float = field( | ||
| default=0.0, metadata={"help": "Filter audio files that are shorter than `min_duration_in_seconds` seconds"} | ||
| default=0.0, | ||
| metadata={"help": "Filter audio files that are shorter than `min_duration_in_seconds` seconds"}, | ||
| ) | ||
| preprocessing_only: bool = field( | ||
| default=False, | ||
|
|
@@ -383,7 +393,8 @@ def extract_all_chars(batch): | |
|
|
||
| # take union of all unique characters in each dataset | ||
| vocab_set = functools.reduce( | ||
| lambda vocab_1, vocab_2: set(vocab_1["vocab"][0]) | set(vocab_2["vocab"][0]), vocabs.values() | ||
| lambda vocab_1, vocab_2: set(vocab_1["vocab"][0]) | set(vocab_2["vocab"][0]), | ||
| vocabs.values(), | ||
| ) | ||
|
|
||
| vocab_dict = {v: k for k, v in enumerate(sorted(vocab_set))} | ||
|
|
@@ -571,7 +582,7 @@ def remove_special_characters(batch): | |
| # it is defined by `tokenizer_class` if present in config else by `model_type` | ||
| tokenizer_kwargs = { | ||
| "config": config if config.tokenizer_class is not None else None, | ||
| "tokenizer_type": config.model_type if config.tokenizer_class is None else None, | ||
| "tokenizer_type": (config.model_type if config.tokenizer_class is None else None), | ||
| "unk_token": unk_token, | ||
| "pad_token": pad_token, | ||
| "word_delimiter_token": word_delimiter_token, | ||
|
|
@@ -639,7 +650,8 @@ def remove_special_characters(batch): | |
| dataset_sampling_rate = next(iter(raw_datasets.values())).features[data_args.audio_column_name].sampling_rate | ||
| if dataset_sampling_rate != feature_extractor.sampling_rate: | ||
| raw_datasets = raw_datasets.cast_column( | ||
| data_args.audio_column_name, datasets.features.Audio(sampling_rate=feature_extractor.sampling_rate) | ||
| data_args.audio_column_name, | ||
| datasets.features.Audio(sampling_rate=feature_extractor.sampling_rate), | ||
| ) | ||
|
|
||
| # derive max & min input length for sample rate & max duration | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.