MCPcopy Create free account
hub / github.com/FunAudioLLM/SenseVoice / __init__

Method __init__

model.py:584–646  ·  view source on GitHub ↗
(
        self,
        specaug: str = None,
        specaug_conf: dict = None,
        normalize: str = None,
        normalize_conf: dict = None,
        encoder: str = None,
        encoder_conf: dict = None,
        ctc_conf: dict = None,
        input_size: int = 80,
        vocab_size: int = -1,
        ignore_id: int = -1,
        blank_id: int = 0,
        sos: int = 1,
        eos: int = 2,
        length_normalized_loss: bool = False,
        **kwargs,
    )

Source from the content-addressed store, hash-verified

582 """CTC-attention hybrid Encoder-Decoder model"""
583
584 def __init__(
585 self,
586 specaug: str = None,
587 specaug_conf: dict = None,
588 normalize: str = None,
589 normalize_conf: dict = None,
590 encoder: str = None,
591 encoder_conf: dict = None,
592 ctc_conf: dict = None,
593 input_size: int = 80,
594 vocab_size: int = -1,
595 ignore_id: int = -1,
596 blank_id: int = 0,
597 sos: int = 1,
598 eos: int = 2,
599 length_normalized_loss: bool = False,
600 **kwargs,
601 ):
602
603 super().__init__()
604
605 if specaug is not None:
606 specaug_class = tables.specaug_classes.get(specaug)
607 specaug = specaug_class(**specaug_conf)
608 if normalize is not None:
609 normalize_class = tables.normalize_classes.get(normalize)
610 normalize = normalize_class(**normalize_conf)
611 encoder_class = tables.encoder_classes.get(encoder)
612 encoder = encoder_class(input_size=input_size, **encoder_conf)
613 encoder_output_size = encoder.output_size()
614
615 if ctc_conf is None:
616 ctc_conf = {}
617 ctc = CTC(odim=vocab_size, encoder_output_size=encoder_output_size, **ctc_conf)
618
619 self.blank_id = blank_id
620 self.sos = sos if sos is not None else vocab_size - 1
621 self.eos = eos if eos is not None else vocab_size - 1
622 self.vocab_size = vocab_size
623 self.ignore_id = ignore_id
624 self.specaug = specaug
625 self.normalize = normalize
626 self.encoder = encoder
627 self.error_calculator = None
628
629 self.ctc = ctc
630
631 self.length_normalized_loss = length_normalized_loss
632 self.encoder_output_size = encoder_output_size
633
634 self.lid_dict = {"auto": 0, "zh": 3, "en": 4, "yue": 7, "ja": 11, "ko": 12, "nospeech": 13}
635 self.lid_int_dict = {24884: 3, 24885: 4, 24888: 7, 24892: 11, 24896: 12, 24992: 13}
636 self.textnorm_dict = {"withitn": 14, "woitn": 15}
637 self.textnorm_int_dict = {25016: 14, 25017: 15}
638 self.embed = torch.nn.Embedding(7 + len(self.lid_dict) + len(self.textnorm_dict), input_size)
639 self.emo_dict = {"unk": 25009, "happy": 25001, "sad": 25002, "angry": 25003, "neutral": 25004}
640
641 self.criterion_att = LabelSmoothingLoss(

Callers

nothing calls this directly

Calls 2

output_sizeMethod · 0.80
__init__Method · 0.45

Tested by

no test coverage detected