Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import base64
|
| 3 |
|
| 4 |
def text_to_srt(text):
|
| 5 |
lines = text.split('\n')
|
|
@@ -15,16 +14,10 @@ def text_to_srt(text):
|
|
| 15 |
continue # Skip lines that don't match the expected format
|
| 16 |
return srt_content
|
| 17 |
|
| 18 |
-
def download_srt(srt_content):
|
| 19 |
-
b64 = base64.b64encode(srt_content.encode()).decode()
|
| 20 |
-
return f'<a download="output.srt" href="text/srt;base64,{b64}">Download SRT</a>'
|
| 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 |
-
download_button = gr.Button(label="Download SRT")
|
| 27 |
text_input.change(fn=text_to_srt, inputs=text_input, outputs=output)
|
| 28 |
-
download_button.click(fn=download_srt, inputs=output, outputs=download_button)
|
| 29 |
|
| 30 |
app.launch()
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
def text_to_srt(text):
|
| 4 |
lines = text.split('\n')
|
|
|
|
| 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()
|