|
import os |
|
import replicate |
|
import gradio as gr |
|
|
|
|
|
REPLICATE_API_TOKEN = "801e5b**********************************" |
|
os.environ["REPLICATE_API_TOKEN"] = REPLICATE_API_TOKEN |
|
|
|
|
|
def generate_subtitles(video): |
|
video_path = video.name |
|
|
|
output = replicate.run( |
|
"fictions-ai/autocaption:18a45ff0d95feb4449d192bbdc06b4a6df168fa33def76dfc51b78ae224b599b", |
|
input={ |
|
"font": "Poppins/Poppins-ExtraBold.ttf", |
|
"color": "white", |
|
"kerning": -5, |
|
"opacity": 0, |
|
"MaxChars": 20, |
|
"fontsize": 3, |
|
"translate": False, |
|
"output_video": True, |
|
"stroke_color": "black", |
|
"stroke_width": 2.6, |
|
"right_to_left": False, |
|
"subs_position": "bottom75", |
|
"highlight_color": "yellow", |
|
"video_file_input": open(video_path, "rb"), |
|
"output_transcript": True |
|
} |
|
) |
|
return output['output_transcript'] |
|
|
|
|
|
def modify_json(json_input): |
|
|
|
return json_input |
|
|
|
|
|
with gr.Blocks() as demo: |
|
video_input = gr.File(label="Subir video") |
|
output_textbox = gr.Textbox(label="JSON de salida", interactive=True) |
|
modify_button = gr.Button("Modificar JSON") |
|
|
|
video_input.upload(generate_subtitles, inputs=video_input, outputs=output_textbox) |
|
modify_button.click(modify_json, inputs=output_textbox, outputs=output_textbox) |
|
|
|
demo.launch() |
|
|