Repository: speechbrain/speechbrain

Issue:
'S2STransformerBeamSearcher' object has no attribute 'ctc_forward_step'
### Describe the bug

Hi all,
I want to test alignment with this code:
```python
from speechbrain.inference.ASR import EncoderDecoderASR
from speechbrain.alignment.ctc_segmentation import CTCSegmentation
# load an ASR model
pre_trained = "speechbrain/asr-transformer-transformerlm-librispeech"
asr_model = EncoderDecoderASR.from_hparams(source=pre_trained)
aligner = CTCSegmentation(asr_model, kaldi_style_text=False)
# load data
audio_path = "/content/speechbrain/tests/samples/single-mic/example1.wav"
text = ["THE BIRCH CANOE", "SLID ON THE", "SMOOTH PLANKS"]
segments = aligner(audio_path, text, name="example1")
```

Script can download model
but I have this error:
```
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
[<ipython-input-4-cb3639878d03>](https://localhost:8080/#) in <cell line: 6>()
      4 pre_trained = "speechbrain/asr-transformer-transformerlm-librispeech"
      5 asr_model = EncoderDecoderASR.from_hparams(source=pre_trained)
----> 6 aligner = CTCSegmentation(asr_model, kaldi_style_text=False)
      7 # load data
      8 audio_path = "/content/speechbrain/tests/samples/single-mic/example1.wav"

1 frames
[/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py](https://localhost:8080/#) in __getattr__(self, name)
   1693             if name in modules:
   1694                 return modules[name]
-> 1695         raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'")
   1696 
   1697     def __setattr__(self, name: str, value: Union[Tensor, 'Module']) -> None:

AttributeError: 'S2STransformerBeamSearcher' object has no attribute 'ctc_forward_step'
```

Thanks in advance for your help !

### Expected behaviour

No error, just use it ;)

### To Reproduce

Steps to reproduce : https://colab.research.google.com/drive/1KmSi3gMppj-664mpzu16qUfdV-h9jG-5?usp=sharing

### Environment Details

```
speechbrain                      1.0.0                 /content/speechbrain
ctc_segmentation                 1.7.4
```

### Relevant Log Output

_No response_

### Additional Context

_No response_


Discussion:
@Adel-Moumen I guess that CTCSegmentation was not adapted to 1.0? 
it seems indeed. I will take a look asap. 

Resolving patch:
diff --git a/speechbrain/alignment/ctc_segmentation.py b/speechbrain/alignment/ctc_segmentation.py
--- a/speechbrain/alignment/ctc_segmentation.py
+++ b/speechbrain/alignment/ctc_segmentation.py
@@ -12,23 +12,23 @@
 import logging
 from pathlib import Path
 from types import SimpleNamespace
-from typing import Optional
-from typing import Union
+from typing import List, Optional, Union
 
 import numpy as np
 import torch
-from typing import List
 
 # speechbrain interface
 from speechbrain.inference.ASR import EncoderASR, EncoderDecoderASR
 
 # imports for CTC segmentation
 try:
-    from ctc_segmentation import ctc_segmentation
-    from ctc_segmentation import CtcSegmentationParameters
-    from ctc_segmentation import determine_utterance_segments
-    from ctc_segmentation import prepare_text
-    from ctc_segmentation import prepare_token_list
+    from ctc_segmentation import (
+        CtcSegmentationParameters,
+        ctc_segmentation,
+        determine_utterance_segments,
+        prepare_text,
+        prepare_token_list,
+    )
 except ImportError:
     print(
         "ImportError: "
@@ -248,9 +248,26 @@ def __init__(
             )
         self.asr_model = asr_model
         self._encode = self.asr_model.encode_batch
+
         if isinstance(asr_model, EncoderDecoderASR):
-            # Assumption: log-softmax is already included in ctc_forward_step
-            self._ctc = self.asr_model.mods.decoder.ctc_forward_step
+            if not hasattr(self.asr_model.hparams, "scorer"):
+                raise AttributeError(
+                    "``ScorerBuilder`` module is required for CTC segmentation."
+                )
+
+            if "ctc" not in self.asr_model.hparams.scorer.full_scorers:
+                raise AttributeError(
+                    "``CTCScorer`` module is required for CTC segmentation."
+                )
+
+            def ctc_forward_step(x: torch.Tensor) -> torch.Tensor:
+                """Forward step for CTC module."""
+                module = self.asr_model.hparams.scorer.full_scorers["ctc"]
+                logits = module.ctc_fc(x)
+                log_probs = module.softmax(logits)
+                return log_probs
+
+            self._ctc = ctc_forward_step
         else:
             # Apply log-softmax to encoder output
             self._ctc = self.asr_model.hparams.log_softmax


Test patch: