Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable transformers as a backend #166

Merged
merged 11 commits into from
Feb 25, 2024
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
},
include_package_data=True,
extras_require={
'dev': ['matplotlib', 'transformers'],
'dev': ['matplotlib==3.7.4', 'transformers'],
'vad_silero': ['onnxruntime', 'torchaudio'],
'vad_auditok': ['auditok'],
'test': ['jsonschema'],
Expand Down
104 changes: 102 additions & 2 deletions tests/json_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,108 @@
},
"language": {"type": "string"},
"language_probs": {
"type": "array",
"items": {"type": "number", "minimum":0, "maximum":1}
"type": "object",
"properties": {
"en": {"type": "number", "minimum":0, "maximum":1},
"zh": {"type": "number", "minimum":0, "maximum":1},
"de": {"type": "number", "minimum":0, "maximum":1},
"es": {"type": "number", "minimum":0, "maximum":1},
"ru": {"type": "number", "minimum":0, "maximum":1},
"ko": {"type": "number", "minimum":0, "maximum":1},
"fr": {"type": "number", "minimum":0, "maximum":1},
"ja": {"type": "number", "minimum":0, "maximum":1},
"pt": {"type": "number", "minimum":0, "maximum":1},
"tr": {"type": "number", "minimum":0, "maximum":1},
"pl": {"type": "number", "minimum":0, "maximum":1},
"ca": {"type": "number", "minimum":0, "maximum":1},
"nl": {"type": "number", "minimum":0, "maximum":1},
"ar": {"type": "number", "minimum":0, "maximum":1},
"sv": {"type": "number", "minimum":0, "maximum":1},
"it": {"type": "number", "minimum":0, "maximum":1},
"id": {"type": "number", "minimum":0, "maximum":1},
"hi": {"type": "number", "minimum":0, "maximum":1},
"fi": {"type": "number", "minimum":0, "maximum":1},
"vi": {"type": "number", "minimum":0, "maximum":1},
"he": {"type": "number", "minimum":0, "maximum":1},
"uk": {"type": "number", "minimum":0, "maximum":1},
"el": {"type": "number", "minimum":0, "maximum":1},
"ms": {"type": "number", "minimum":0, "maximum":1},
"cs": {"type": "number", "minimum":0, "maximum":1},
"ro": {"type": "number", "minimum":0, "maximum":1},
"da": {"type": "number", "minimum":0, "maximum":1},
"hu": {"type": "number", "minimum":0, "maximum":1},
"ta": {"type": "number", "minimum":0, "maximum":1},
"no": {"type": "number", "minimum":0, "maximum":1},
"th": {"type": "number", "minimum":0, "maximum":1},
"ur": {"type": "number", "minimum":0, "maximum":1},
"hr": {"type": "number", "minimum":0, "maximum":1},
"bg": {"type": "number", "minimum":0, "maximum":1},
"lt": {"type": "number", "minimum":0, "maximum":1},
"la": {"type": "number", "minimum":0, "maximum":1},
"mi": {"type": "number", "minimum":0, "maximum":1},
"ml": {"type": "number", "minimum":0, "maximum":1},
"cy": {"type": "number", "minimum":0, "maximum":1},
"sk": {"type": "number", "minimum":0, "maximum":1},
"te": {"type": "number", "minimum":0, "maximum":1},
"fa": {"type": "number", "minimum":0, "maximum":1},
"lv": {"type": "number", "minimum":0, "maximum":1},
"bn": {"type": "number", "minimum":0, "maximum":1},
"sr": {"type": "number", "minimum":0, "maximum":1},
"az": {"type": "number", "minimum":0, "maximum":1},
"sl": {"type": "number", "minimum":0, "maximum":1},
"kn": {"type": "number", "minimum":0, "maximum":1},
"et": {"type": "number", "minimum":0, "maximum":1},
"mk": {"type": "number", "minimum":0, "maximum":1},
"br": {"type": "number", "minimum":0, "maximum":1},
"eu": {"type": "number", "minimum":0, "maximum":1},
"is": {"type": "number", "minimum":0, "maximum":1},
"hy": {"type": "number", "minimum":0, "maximum":1},
"ne": {"type": "number", "minimum":0, "maximum":1},
"mn": {"type": "number", "minimum":0, "maximum":1},
"bs": {"type": "number", "minimum":0, "maximum":1},
"kk": {"type": "number", "minimum":0, "maximum":1},
"sq": {"type": "number", "minimum":0, "maximum":1},
"sw": {"type": "number", "minimum":0, "maximum":1},
"gl": {"type": "number", "minimum":0, "maximum":1},
"mr": {"type": "number", "minimum":0, "maximum":1},
"pa": {"type": "number", "minimum":0, "maximum":1},
"si": {"type": "number", "minimum":0, "maximum":1},
"km": {"type": "number", "minimum":0, "maximum":1},
"sn": {"type": "number", "minimum":0, "maximum":1},
"yo": {"type": "number", "minimum":0, "maximum":1},
"so": {"type": "number", "minimum":0, "maximum":1},
"af": {"type": "number", "minimum":0, "maximum":1},
"oc": {"type": "number", "minimum":0, "maximum":1},
"ka": {"type": "number", "minimum":0, "maximum":1},
"be": {"type": "number", "minimum":0, "maximum":1},
"tg": {"type": "number", "minimum":0, "maximum":1},
"sd": {"type": "number", "minimum":0, "maximum":1},
"gu": {"type": "number", "minimum":0, "maximum":1},
"am": {"type": "number", "minimum":0, "maximum":1},
"yi": {"type": "number", "minimum":0, "maximum":1},
"lo": {"type": "number", "minimum":0, "maximum":1},
"uz": {"type": "number", "minimum":0, "maximum":1},
"fo": {"type": "number", "minimum":0, "maximum":1},
"ht": {"type": "number", "minimum":0, "maximum":1},
"ps": {"type": "number", "minimum":0, "maximum":1},
"tk": {"type": "number", "minimum":0, "maximum":1},
"nn": {"type": "number", "minimum":0, "maximum":1},
"mt": {"type": "number", "minimum":0, "maximum":1},
"sa": {"type": "number", "minimum":0, "maximum":1},
"lb": {"type": "number", "minimum":0, "maximum":1},
"my": {"type": "number", "minimum":0, "maximum":1},
"bo": {"type": "number", "minimum":0, "maximum":1},
"tl": {"type": "number", "minimum":0, "maximum":1},
"mg": {"type": "number", "minimum":0, "maximum":1},
"as": {"type": "number", "minimum":0, "maximum":1},
"tt": {"type": "number", "minimum":0, "maximum":1},
"haw": {"type": "number", "minimum":0, "maximum":1},
"ln": {"type": "number", "minimum":0, "maximum":1},
"ha": {"type": "number", "minimum":0, "maximum":1},
"ba": {"type": "number", "minimum":0, "maximum":1},
"jw": {"type": "number", "minimum":0, "maximum":1},
"su": {"type": "number", "minimum":0, "maximum":1}
}
}
}
}
4 changes: 3 additions & 1 deletion tests/test_transcribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,15 +661,17 @@ def test_hugging_face_model(self):
)

import tempfile
from transformers import WhisperForConditionalGeneration
from transformers import WhisperForConditionalGeneration, WhisperProcessor, GenerationConfig
tempfolder = os.path.join(tempfile.gettempdir(), "tmp_whisper-tiny-french-cased")

for safe_serialization in False, True,:
for max_shard_size in "100MB", "10GB", :
shutil.rmtree(tempfolder, ignore_errors=True)
model = WhisperForConditionalGeneration.from_pretrained("qanastek/whisper-tiny-french-cased")
processor = WhisperProcessor.from_pretrained("qanastek/whisper-tiny-french-cased")
try:
model.save_pretrained(tempfolder, safe_serialization=safe_serialization, max_shard_size=max_shard_size)
processor.save_pretrained(tempfolder)
self._test_cli_(
["--model", tempfolder, "--verbose", "True"],
"verbose", files=["bonjour.wav"], extensions=None,
Expand Down
Loading