Automatic Speech Recognition
Transformers
TensorBoard
Safetensors
msp
Generated from Trainer
custom_code
Instructions to use MahmoodAnaam/MSP with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MahmoodAnaam/MSP with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("automatic-speech-recognition", model="MahmoodAnaam/MSP", trust_remote_code=True)# Load model directly from transformers import AutoModelForCTC model = AutoModelForCTC.from_pretrained("MahmoodAnaam/MSP", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
File size: 1,441 Bytes
dc0059b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | from transformers.processing_utils import ProcessorMixin
class MSPProcessor(ProcessorMixin):
attributes = ["feature_extractor", "video_processor", "tokenizer"]
feature_extractor_class = "AutoFeatureExtractor"
video_processor_class = "AutoVideoProcessor"
tokenizer_class = "AutoTokenizer"
def __init__(
self, feature_extractor=None, video_processor=None, tokenizer=None, **kwargs
):
super().__init__(feature_extractor, video_processor, tokenizer, **kwargs)
self.feature_extractor = feature_extractor
self.video_processor = video_processor
self.tokenizer = tokenizer
def __call__(
self,
audio=None,
videos=None,
text=None,
**kwargs,
):
if audio is None and videos is None and text is None:
raise ValueError("Provide at least one of audio, videos, or text.")
inputs = super().__call__(
images=None, audio=audio, videos=videos, text=text, **kwargs
)
if "input_ids" in inputs:
inputs["labels"] = inputs.pop("input_ids")
if "attention_mask" in inputs:
inputs.pop("attention_mask")
return inputs
@property
def model_input_names(self) -> list[str]:
return [
"input_values",
"padding_mask",
"pixel_values_videos",
"padding_mask_videos",
"labels",
]
|