mirror of
https://github.com/modelscope/FunASR
synced 2025-09-15 14:48:36 +08:00
update
This commit is contained in:
parent
68550b6b9b
commit
bb2113434a
@ -6,13 +6,10 @@ import torch
|
|||||||
import torch.nn as nn
|
import torch.nn as nn
|
||||||
|
|
||||||
from funasr.modules.embedding import SinusoidalPositionEncoder
|
from funasr.modules.embedding import SinusoidalPositionEncoder
|
||||||
#from funasr.models.encoder.transformer_encoder import TransformerEncoder as Encoder
|
|
||||||
from funasr.models.encoder.sanm_encoder import SANMEncoder as Encoder
|
from funasr.models.encoder.sanm_encoder import SANMEncoder as Encoder
|
||||||
#from funasr.modules.mask import subsequent_n_mask
|
|
||||||
from funasr.train.abs_model import AbsPunctuation
|
|
||||||
|
|
||||||
|
|
||||||
class TargetDelayTransformer(AbsPunctuation):
|
class TargetDelayTransformer(torch.nn.Module):
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
|||||||
@ -7,10 +7,9 @@ import torch.nn as nn
|
|||||||
|
|
||||||
from funasr.modules.embedding import SinusoidalPositionEncoder
|
from funasr.modules.embedding import SinusoidalPositionEncoder
|
||||||
from funasr.models.encoder.sanm_encoder import SANMVadEncoder as Encoder
|
from funasr.models.encoder.sanm_encoder import SANMVadEncoder as Encoder
|
||||||
from funasr.train.abs_model import AbsPunctuation
|
|
||||||
|
|
||||||
|
|
||||||
class VadRealtimeTransformer(AbsPunctuation):
|
class VadRealtimeTransformer(torch.nn.Module):
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
|||||||
@ -12,34 +12,12 @@ from typeguard import check_argument_types
|
|||||||
|
|
||||||
from funasr.modules.nets_utils import make_pad_mask
|
from funasr.modules.nets_utils import make_pad_mask
|
||||||
from funasr.torch_utils.device_funcs import force_gatherable
|
from funasr.torch_utils.device_funcs import force_gatherable
|
||||||
from funasr.train.abs_espnet_model import AbsESPnetModel
|
from funasr.models.base_model import FunASRModel
|
||||||
|
|
||||||
from funasr.modules.scorers.scorer_interface import BatchScorerInterface
|
|
||||||
|
|
||||||
|
|
||||||
class AbsPunctuation(torch.nn.Module, BatchScorerInterface, ABC):
|
class PunctuationModel(FunASRModel):
|
||||||
"""The abstract class
|
|
||||||
|
|
||||||
To share the loss calculation way among different models,
|
def __init__(self, punc_model: torch.nn.Module, vocab_size: int, ignore_id: int = 0, punc_weight: list = None):
|
||||||
We uses delegate pattern here:
|
|
||||||
The instance of this class should be passed to "LanguageModel"
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
class PunctuationModel(AbsESPnetModel):
|
|
||||||
|
|
||||||
def __init__(self, punc_model: AbsPunctuation, vocab_size: int, ignore_id: int = 0, punc_weight: list = None):
|
|
||||||
assert check_argument_types()
|
assert check_argument_types()
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.punc_model = punc_model
|
self.punc_model = punc_model
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user