espnet2.asvspoof package

espnet2.asvspoof.espnet_model

class espnet2.asvspoof.espnet_model.ESPnetASVSpoofModel(frontend: Optional[espnet2.asr.frontend.abs_frontend.AbsFrontend], specaug: Optional[espnet2.asr.specaug.abs_specaug.AbsSpecAug], normalize: Optional[espnet2.layers.abs_normalize.AbsNormalize], encoder: espnet2.asr.encoder.abs_encoder.AbsEncoder, preencoder: Optional[espnet2.asr.preencoder.abs_preencoder.AbsPreEncoder], decoder: espnet2.asvspoof.decoder.abs_decoder.AbsDecoder, losses: Dict[str, espnet2.asvspoof.loss.abs_loss.AbsASVSpoofLoss])[source]

Bases: espnet2.train.abs_espnet_model.AbsESPnetModel

ASV Spoofing model A simple ASV Spoofing model

collect_feats(speech: torch.Tensor, speech_lengths: torch.Tensor, **kwargs) → Dict[str, torch.Tensor][source]
encode(speech: torch.Tensor, speech_lengths: torch.Tensor) → Tuple[torch.Tensor, torch.Tensor][source]

Frontend + Encoder :param speech: (Batch, Length, …) :param speech_lengths: (Batch,) :param bottleneck_feats: (Batch, Length, …): used for enh + diar

forward(speech: torch.Tensor, speech_lengths: torch.Tensor = None, label: torch.Tensor = None, **kwargs) → Tuple[torch.Tensor, Dict[str, torch.Tensor], torch.Tensor][source]

Frontend + Encoder + Decoder + Calc loss :param speech: (Batch, samples) :param spk_labels: (Batch, ) :param kwargs: “utt_id” is among the input.

espnet2.asvspoof.__init__

espnet2.asvspoof.loss.binary_loss

class espnet2.asvspoof.loss.binary_loss.ASVSpoofBinaryLoss(weight: float = 1.0)[source]

Bases: espnet2.asvspoof.loss.abs_loss.AbsASVSpoofLoss

Binary loss for ASV Spoofing.

forward(pred: torch.Tensor, label: torch.Tensor, **kwargs)[source]

Forward. :param pred: prediction probability [Batch, 2] :type pred: torch.Tensor :param label: ground truth label [Batch, 2] :type label: torch.Tensor

score(pred: torch.Tensor)[source]

espnet2.asvspoof.loss.am_softmax_loss

class espnet2.asvspoof.loss.am_softmax_loss.ASVSpoofAMSoftmaxLoss(weight: float = 1.0, enc_dim: int = 128, s: float = 20, m: float = 0.5)[source]

Bases: espnet2.asvspoof.loss.abs_loss.AbsASVSpoofLoss

Binary loss for ASV Spoofing.

forward(label: torch.Tensor, emb: torch.Tensor, **kwargs)[source]

Forward. :param label: ground truth label [Batch, 1] :type label: torch.Tensor :param emb: encoder embedding output [Batch, T, enc_dim] :type emb: torch.Tensor

score(emb: torch.Tensor)[source]

Prediction. :param emb: encoder embedding output [Batch, T, enc_dim] :type emb: torch.Tensor

espnet2.asvspoof.loss.oc_softmax_loss

class espnet2.asvspoof.loss.oc_softmax_loss.ASVSpoofOCSoftmaxLoss(weight: float = 1.0, enc_dim: int = 128, m_real: float = 0.5, m_fake: float = 0.2, alpha: float = 20.0)[source]

Bases: espnet2.asvspoof.loss.abs_loss.AbsASVSpoofLoss

Binary loss for ASV Spoofing.

forward(label: torch.Tensor, emb: torch.Tensor, **kwargs)[source]

Forward. :param label: ground truth label [Batch, 1] :type label: torch.Tensor :param emb: encoder embedding output [Batch, T, enc_dim] :type emb: torch.Tensor

score(emb: torch.Tensor)[source]

Prediction. :param emb: encoder embedding output [Batch, T, enc_dim] :type emb: torch.Tensor

espnet2.asvspoof.loss.__init__

espnet2.asvspoof.loss.abs_loss

class espnet2.asvspoof.loss.abs_loss.AbsASVSpoofLoss[source]

Bases: torch.nn.modules.module.Module, abc.ABC

Base class for all ASV Spoofing loss modules.

Initializes internal Module state, shared by both nn.Module and ScriptModule.

abstract forward(ref, inf) → torch.Tensor[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

property name
abstract score(pred) → torch.Tensor[source]

espnet2.asvspoof.decoder.abs_decoder

class espnet2.asvspoof.decoder.abs_decoder.AbsDecoder[source]

Bases: torch.nn.modules.module.Module, abc.ABC

Initializes internal Module state, shared by both nn.Module and ScriptModule.

abstract forward(input: torch.Tensor, ilens: torch.Tensor) → Tuple[torch.Tensor, torch.Tensor][source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

espnet2.asvspoof.decoder.__init__

espnet2.asvspoof.decoder.linear_decoder

class espnet2.asvspoof.decoder.linear_decoder.LinearDecoder(encoder_output_size: int)[source]

Bases: espnet2.asvspoof.decoder.abs_decoder.AbsDecoder

Linear decoder for speaker diarization

forward(input: torch.Tensor, ilens: Optional[torch.Tensor])[source]

Forward. :param input: hidden_space [Batch, T, F] :type input: torch.Tensor :param ilens: input lengths [Batch] :type ilens: torch.Tensor