Auto feature extractor (#11097)

* AutoFeatureExtractor

* Init and first tests

* Tests

* Damn you gitignore

* Quality

* Defensive test for when not all backends are here

* Use pattern for Speech2Text models
This commit is contained in:
Sylvain Gugger
2021-04-06 19:20:08 -04:00
committed by GitHub
parent 520198f56f
commit 403d530eec
18 changed files with 309 additions and 34 deletions

View File

@@ -20,12 +20,15 @@ import unittest
import numpy as np
from transformers import Speech2TextFeatureExtractor
from transformers import is_speech_available
from transformers.testing_utils import require_torch, require_torchaudio
from .test_sequence_feature_extraction_common import SequenceFeatureExtractionTestMixin
if is_speech_available():
from transformers import Speech2TextFeatureExtractor
global_rng = random.Random()
@@ -101,7 +104,7 @@ class Speech2TextFeatureExtractionTester(unittest.TestCase):
@require_torchaudio
class Speech2TextFeatureExtractionTest(SequenceFeatureExtractionTestMixin, unittest.TestCase):
feature_extraction_class = Speech2TextFeatureExtractor
feature_extraction_class = Speech2TextFeatureExtractor if is_speech_available() else None
def setUp(self):
self.feat_extract_tester = Speech2TextFeatureExtractionTester(self)