add validation for other video formats; double cache size; adapt to device_type change in transcriber
fc6dd1b Download utils/transcriber.py from marquesafonso/multilang-asr-captioner: direct link, hf CLI and curl.
- Browser
- Download file 805 Bytes
-
https://huggingface.co/spaces/marquesafonso/multilang-asr-captioner/resolve/main/utils/transcriber.py
- Command line
-
hf download hf://spaces/marquesafonso/multilang-asr-captioner/utils/transcriber.py
-
curl -L -o transcriber.py https://huggingface.co/spaces/marquesafonso/multilang-asr-captioner/resolve/main/utils/transcriber.py
805 Bytes
| import os | |
| from gradio_client import Client, handle_file | |
| from dotenv import load_dotenv | |
| def transcriber(invideo_file:str, | |
| max_words_per_line:int, | |
| task:str, | |
| model_version:str, | |
| device_type:str | |
| ): | |
| load_dotenv() | |
| HF_TOKEN = os.getenv("HF_TOKEN") | |
| HF_SPACE = os.getenv("HF_SPACE") | |
| client = Client(HF_SPACE, hf_token=HF_TOKEN) | |
| result = client.predict( | |
| file_input=handle_file(invideo_file), | |
| file_type = "video", | |
| max_words_per_line=max_words_per_line, | |
| task=task, | |
| model_version=model_version, | |
| device_type=device_type, | |
| api_name="/predict" | |
| ) | |
| return result[0], result[3] |