File size: 737 Bytes
d7fa99f c3fdd00 748e637 31ddfb8 c3fdd00 d7fa99f 748e637 31ddfb8 748e637 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
import os
from dotenv import load_dotenv
from gradio_client import Client, handle_file
def transcriber(invideo_file:str, srt_file:str,
max_words_per_line:int, task:str, model_version: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(
video_input=handle_file(invideo_file),
max_words_per_line=max_words_per_line,
task=task,
model_version=model_version,
api_name="/predict"
)
with open(srt_file, "w", encoding='utf-8') as file:
file.write(result[0])
return srt_file |