Upload custom_interface_local.py with huggingface_hub (#5)
Browse files- Upload custom_interface_local.py with huggingface_hub (1c98e93f4b49b1331356e63e0452632269ed42de)
Co-authored-by: Lukenyanja thomas <[email protected]>
- custom_interface_local.py +17 -0
custom_interface_local.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from speechbrain.pretrained import EncoderClassifier
|
| 2 |
+
from transformers import AutoProcessor, Wav2Vec2Processor
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
class CustomEncoderWav2vec2Classifier(EncoderClassifier):
|
| 6 |
+
"""
|
| 7 |
+
This class inherits from `EncoderClassifier` to handle custom models.
|
| 8 |
+
|
| 9 |
+
The only difference is that it uses `AutoProcessor` to load the tokenizer.
|
| 10 |
+
"""
|
| 11 |
+
|
| 12 |
+
def __init__(self, *args, **kwargs):
|
| 13 |
+
super().__init__(*args, **kwargs)
|
| 14 |
+
self.tokenizer = AutoProcessor.from_pretrained(
|
| 15 |
+
self.hparams.source, trust_remote_code=True
|
| 16 |
+
)
|
| 17 |
+
|