speech_asr
2023-03-10 e1dc7e311e3b469eeb75bc0d59e1e24e0d5bb7e4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from abc import ABC
from abc import abstractmethod
from typing import Tuple
 
import torch
 
from funasr.modules.scorers.scorer_interface import BatchScorerInterface
 
 
class AbsPunctuation(torch.nn.Module, BatchScorerInterface, ABC):
    """The abstract class
 
    To share the loss calculation way among different models,
    We uses delegate pattern here:
    The instance of this class should be passed to "LanguageModel"
 
    >>> from funasr.punctuation.abs_model import AbsPunctuation
    >>> punc = AbsPunctuation()
    >>> model = ESPnetPunctuationModel(punc=punc)
 
    This "model" is one of mediator objects for "Task" class.
 
    """
 
    @abstractmethod
    def forward(self, input: torch.Tensor, hidden: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor]:
        raise NotImplementedError
 
    @abstractmethod
    def with_vad(self) -> bool:
        raise NotImplementedError