huzy0 commited on
Commit
c2c8318
·
verified ·
1 Parent(s): 8c8d6a5

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": 30,
7
  "feature_extractor_type": "ModifiedWhisperFeatureExtractor",
8
  "feature_size": 80,
9
  "hop_length": 160,
10
  "n_fft": 400,
11
- "n_samples": 480000,
12
- "nb_max_frames": 3000,
13
  "padding_side": "right",
14
  "padding_value": 0.0,
15
- "return_attention_mask": false,
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=30,
83
  n_fft=400,
84
  padding_value=0.0,
85
- return_attention_mask=False, # pad inputs to max length with silence token (zero) and no 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] = None,
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)