File size: 1,608 Bytes
d6b70d3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a0b2022
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import os
import replicate
import gradio as gr

# Función para procesar el video y generar subtítulos
def generate_subtitles(api_token, video):
    os.environ["REPLICATE_API_TOKEN"] = api_token
    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:
    api_token_input = gr.Textbox(label="API Token", type="password")
    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=[api_token_input, video_input], outputs=output_textbox)
    modify_button.click(modify_json, inputs=output_textbox, outputs=output_textbox)

demo.launch()