Feature Extraction
Transformers
Safetensors
meralion_bestrq
speech
best-rq
meralion
meralion-2
custom_code
Instructions to use MERaLiON/MERaLiON-SpeechEncoder-2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MERaLiON/MERaLiON-SpeechEncoder-2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="MERaLiON/MERaLiON-SpeechEncoder-2", trust_remote_code=True)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("MERaLiON/MERaLiON-SpeechEncoder-2", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Upload feature extractor
Browse files
preprocessor_config.json
CHANGED
|
@@ -3,15 +3,15 @@
|
|
| 3 |
"AutoFeatureExtractor": "processing_bestrq_conformer.ModifiedWhisperFeatureExtractor",
|
| 4 |
"AutoProcessor": "processing_bestrq_conformer.ModifiedWhisperFeatureExtractor"
|
| 5 |
},
|
| 6 |
-
"chunk_length":
|
| 7 |
"feature_extractor_type": "ModifiedWhisperFeatureExtractor",
|
| 8 |
"feature_size": 80,
|
| 9 |
"hop_length": 160,
|
| 10 |
"n_fft": 400,
|
| 11 |
-
"n_samples":
|
| 12 |
-
"nb_max_frames":
|
| 13 |
"padding_side": "right",
|
| 14 |
"padding_value": 0.0,
|
| 15 |
-
"return_attention_mask":
|
| 16 |
"sampling_rate": 16000
|
| 17 |
}
|
|
|
|
| 3 |
"AutoFeatureExtractor": "processing_bestrq_conformer.ModifiedWhisperFeatureExtractor",
|
| 4 |
"AutoProcessor": "processing_bestrq_conformer.ModifiedWhisperFeatureExtractor"
|
| 5 |
},
|
| 6 |
+
"chunk_length": 120,
|
| 7 |
"feature_extractor_type": "ModifiedWhisperFeatureExtractor",
|
| 8 |
"feature_size": 80,
|
| 9 |
"hop_length": 160,
|
| 10 |
"n_fft": 400,
|
| 11 |
+
"n_samples": 1920000,
|
| 12 |
+
"nb_max_frames": 12000,
|
| 13 |
"padding_side": "right",
|
| 14 |
"padding_value": 0.0,
|
| 15 |
+
"return_attention_mask": true,
|
| 16 |
"sampling_rate": 16000
|
| 17 |
}
|
processing_bestrq_conformer.py
CHANGED
|
@@ -22,7 +22,6 @@ from shutil import copyfile
|
|
| 22 |
from typing import Dict, List, Optional, Tuple, Union
|
| 23 |
|
| 24 |
import numpy as np
|
| 25 |
-
import sentencepiece as spm
|
| 26 |
|
| 27 |
from transformers import is_torch_available, AutoFeatureExtractor, AutoTokenizer
|
| 28 |
from transformers.audio_utils import mel_filter_bank, spectrogram, window_function
|
|
@@ -79,10 +78,10 @@ class ModifiedWhisperFeatureExtractor(SequenceFeatureExtractor):
|
|
| 79 |
feature_size=80,
|
| 80 |
sampling_rate=16000,
|
| 81 |
hop_length=160,
|
| 82 |
-
chunk_length=
|
| 83 |
n_fft=400,
|
| 84 |
padding_value=0.0,
|
| 85 |
-
return_attention_mask=
|
| 86 |
**kwargs,
|
| 87 |
):
|
| 88 |
super().__init__(
|
|
@@ -190,7 +189,7 @@ class ModifiedWhisperFeatureExtractor(SequenceFeatureExtractor):
|
|
| 190 |
truncation: bool = True,
|
| 191 |
pad_to_multiple_of: Optional[int] = None,
|
| 192 |
return_tensors: Optional[Union[str, TensorType]] = None,
|
| 193 |
-
return_attention_mask: Optional[bool] =
|
| 194 |
padding: Optional[Union[bool, str]] = True,
|
| 195 |
max_length: Optional[int] = None,
|
| 196 |
sampling_rate: Optional[int] = None,
|
|
@@ -364,6 +363,8 @@ class MeralionBestRqConformerTokenizer(PreTrainedTokenizer):
|
|
| 364 |
blank_token="<blk>",
|
| 365 |
**kwargs
|
| 366 |
):
|
|
|
|
|
|
|
| 367 |
self.vocab_file = vocab_file
|
| 368 |
self.sp_model = spm.SentencePieceProcessor()
|
| 369 |
self.sp_model.Load(vocab_file)
|
|
|
|
| 22 |
from typing import Dict, List, Optional, Tuple, Union
|
| 23 |
|
| 24 |
import numpy as np
|
|
|
|
| 25 |
|
| 26 |
from transformers import is_torch_available, AutoFeatureExtractor, AutoTokenizer
|
| 27 |
from transformers.audio_utils import mel_filter_bank, spectrogram, window_function
|
|
|
|
| 78 |
feature_size=80,
|
| 79 |
sampling_rate=16000,
|
| 80 |
hop_length=160,
|
| 81 |
+
chunk_length=120,
|
| 82 |
n_fft=400,
|
| 83 |
padding_value=0.0,
|
| 84 |
+
return_attention_mask=True, # pad inputs to max length with silence token (zero) and no attention mask
|
| 85 |
**kwargs,
|
| 86 |
):
|
| 87 |
super().__init__(
|
|
|
|
| 189 |
truncation: bool = True,
|
| 190 |
pad_to_multiple_of: Optional[int] = None,
|
| 191 |
return_tensors: Optional[Union[str, TensorType]] = None,
|
| 192 |
+
return_attention_mask: Optional[bool] = True,
|
| 193 |
padding: Optional[Union[bool, str]] = True,
|
| 194 |
max_length: Optional[int] = None,
|
| 195 |
sampling_rate: Optional[int] = None,
|
|
|
|
| 363 |
blank_token="<blk>",
|
| 364 |
**kwargs
|
| 365 |
):
|
| 366 |
+
import sentencepiece as spm
|
| 367 |
+
|
| 368 |
self.vocab_file = vocab_file
|
| 369 |
self.sp_model = spm.SentencePieceProcessor()
|
| 370 |
self.sp_model.Load(vocab_file)
|