Upload audio/DF_Arena_1B_V_1/modeling_antispoofing.py with huggingface_hub
Browse files
audio/DF_Arena_1B_V_1/modeling_antispoofing.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
import torch.nn as nn
|
| 3 |
+
from transformers import PreTrainedModel
|
| 4 |
+
from .configuration_antispoofing import DF_Arena_1B_Config
|
| 5 |
+
from .backbone import DF_Arena_1B
|
| 6 |
+
from .feature_extraction_antispoofing import AntispoofingFeatureExtractor
|
| 7 |
+
|
| 8 |
+
class DF_Arena_1B_Antispoofing(PreTrainedModel):
|
| 9 |
+
config_class = DF_Arena_1B_Config
|
| 10 |
+
|
| 11 |
+
def __init__(self, config: DF_Arena_1B_Config):
|
| 12 |
+
super().__init__(config)
|
| 13 |
+
self.feature_extractor = AntispoofingFeatureExtractor()
|
| 14 |
+
# your backbone here (CNN/TDNN/Wav2Vec front-end, etc.)
|
| 15 |
+
self.backbone = DF_Arena_1B()
|
| 16 |
+
self.post_init()
|
| 17 |
+
|
| 18 |
+
def forward(self, input_values, attention_mask=None):
|
| 19 |
+
# input_values: (batch, time) float32 waveform @ config.sample_rate
|
| 20 |
+
logits = self.backbone(input_values)
|
| 21 |
+
return {"logits": logits}
|