# How to apply SpecAugment to a Whisper?

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-apply-specaugment-to-a-whisper%2F40435%3E%5C
**Category:** 🤗Transformers\
**Created:** [May 20, 2023, 3:55am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-apply-specaugment-to-a-whisper%2F40435 "2023-05-20T03:55:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mehran](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/mehran/32/18522_2.png) [@mehran](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fmehran)%5C
**Post date:** [May 20, 2023, 3:55am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-apply-specaugment-to-a-whisper%2F40435%2F1 "2023-05-20T03:55:34Z")

</div>

I’m trying to learn how I can apply SpecAugment when fine tuning a Whisper model. First of all, I’m not sure if applying such augmentation is common practice for fine tuning or not (maybe it’s only used for training?). And second, I don’t even know how to implement it.

I see that PyTorch has a [library](https://pytorch.org/audio/master/tutorials/audio_feature_augmentation_tutorial.html) implementing the technique. But I guess I need to take into account the mask for each sample before using that library. And I don’t know how to do that.

I appreciate any guidance I can get. Thanks.

---

<div class="post-metadata">

**Author:** ![Kongda](https://avatars.discourse-cdn.com/v4/letter/k/858c86/32.png) [@Kongda](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FKongda)%5C
**Post date:** [July 25, 2023, 5:31am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-apply-specaugment-to-a-whisper%2F40435%2F2 "2023-07-25T05:31:21Z")

</div>

HI, I share the same question as well. Have you managed to sovle this issue?

---

<div class="post-metadata">

**Author:** ![mehran](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/mehran/32/18522_2.png) [@mehran](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fmehran)%5C
**Post date:** [August 13, 2023, 8:37pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-apply-specaugment-to-a-whisper%2F40435%2F3 "2023-08-13T20:37:28Z")

</div>

I’m not if this is the right way to do it but it seem to work:

```auto
from transformers import WhisperForConditionalGeneration

model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-small")

model.config.forced_decoder_ids = None
model.config.suppress_tokens = []

model.config.apply_spec_augment = True
model.config.mask_time_prob = 0.05
model.config.mask_feature_prob = 0.05

```

The last three lines enable the SpecAug for the Whisper model. The right values to set need to be researched.

---

<div class="post-metadata">

**Author:** ![anahar](https://avatars.discourse-cdn.com/v4/letter/a/c77e96/32.png) [@anahar](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fanahar)%5C
**Post date:** [February 9, 2024, 7:43am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-apply-specaugment-to-a-whisper%2F40435%2F4 "2024-02-09T07:43:41Z")

</div>

Hey @mehran have you observed any noticeable improvements in performance metrics after applying the SpecAugment?
