Repository: speechbrain/speechbrain
Issue category: Bug Report

Issue:
Syntax Bug in Librispeech Whisper Recipe
### Describe the bug

These bugs listed below are related to whisper specifically following this [recipe](recipes/LibriSpeech/ASR/transformer/train_with_whisper.py)
1) line 228 in dataio_prepare, hparams is a dictionary so `hasattr(hparams, "normalized_transcripts")` does not work as intended.

2) line 50. I've gotten some rounding issues for some batches where the .long() rounds down rather than to the nearest int. (i.e. 12.998 gets rounded down to 12, excluding the last token).

### Expected behaviour

1) just change syntax to check keys in dictionary
2) use torch.round() to ensure proper mask computation

### To Reproduce

_No response_

### Environment Details

_No response_

### Relevant Log Output

_No response_

### Additional Context

_No response_


Hints:
Hi @matthewkperez, thanks for opening this issue! Would you like to open a PR to fix it? It would be a very welcome contribution :) 
Just submitted PR #2737 for this. Cheers!

Patch:
diff --git a/recipes/LibriSpeech/ASR/transformer/train_with_whisper.py b/recipes/LibriSpeech/ASR/transformer/train_with_whisper.py
index 5c65a49682..90e0d118d3 100644
--- a/recipes/LibriSpeech/ASR/transformer/train_with_whisper.py
+++ b/recipes/LibriSpeech/ASR/transformer/train_with_whisper.py
@@ -107,7 +107,6 @@ def compute_objectives(self, predictions, batch, stage):
             target_words = self.tokenizer.batch_decode(
                 target_words, skip_special_tokens=True
             )
-
             if hasattr(self.hparams, "normalized_transcripts"):
 
                 if hasattr(self.tokenizer, "normalize"):
@@ -237,7 +236,10 @@ def audio_pipeline(wav):
         "wrd", "tokens_list", "tokens_bos", "tokens_eos", "tokens"
     )
     def text_pipeline(wrd):
-        if "normalized_transcripts" in hparams:
+        if (
+            "normalized_transcripts" in hparams
+            and hparams["normalized_transcripts"]
+        ):
             wrd = tokenizer.normalize(wrd)
         yield wrd
         tokens_list = tokenizer.encode(wrd, add_special_tokens=False)


Test patch: