Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -14,10 +14,17 @@ def text_to_srt(text):
|
|
14 |
continue # Skip lines that don't match the expected format
|
15 |
return srt_content
|
16 |
|
|
|
|
|
|
|
|
|
|
|
17 |
with gr.Blocks() as app:
|
18 |
gr.Markdown("### Text to SRT Converter")
|
19 |
text_input = gr.TextArea(label="Enter text in the specified format")
|
20 |
output = gr.TextArea(label="SRT Output")
|
|
|
21 |
text_input.change(fn=text_to_srt, inputs=text_input, outputs=output)
|
|
|
22 |
|
23 |
-
app.launch()
|
|
|
14 |
continue # Skip lines that don't match the expected format
|
15 |
return srt_content
|
16 |
|
17 |
+
def export_file(srt_content):
|
18 |
+
if srt_content.strip() == "":
|
19 |
+
return None
|
20 |
+
return gr.File(content=srt_content.encode('utf-8'), file_name="output.srt")
|
21 |
+
|
22 |
with gr.Blocks() as app:
|
23 |
gr.Markdown("### Text to SRT Converter")
|
24 |
text_input = gr.TextArea(label="Enter text in the specified format")
|
25 |
output = gr.TextArea(label="SRT Output")
|
26 |
+
export_button = gr.Button("Export as SRT")
|
27 |
text_input.change(fn=text_to_srt, inputs=text_input, outputs=output)
|
28 |
+
export_button.click(fn=export_file, inputs=output, outputs=gr.File(label="Download SRT"))
|
29 |
|
30 |
+
app.launch()
|