vs / app.py
GAS17's picture
Update app.py
a541fdd verified
import os
import replicate
import gradio as gr
# Configura tu token de API de Replicate
REPLICATE_API_TOKEN = "801e5b**********************************"
os.environ["REPLICATE_API_TOKEN"] = REPLICATE_API_TOKEN
# Funci贸n para procesar el video y generar subt铆tulos
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']
# Interfaz de Gradio
def modify_json(json_input):
# Esta funci贸n simplemente retorna el JSON modificado
return json_input
# Definir los componentes de la interfaz
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()