Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
def text_to_srt(text):
|
| 4 |
lines = text.split('\n')
|
|
@@ -17,7 +18,9 @@ def text_to_srt(text):
|
|
| 17 |
def export_file(srt_content):
|
| 18 |
if srt_content.strip() == "":
|
| 19 |
return None
|
| 20 |
-
|
|
|
|
|
|
|
| 21 |
|
| 22 |
with gr.Blocks() as app:
|
| 23 |
gr.Markdown("### Text to SRT Converter")
|
|
@@ -27,4 +30,4 @@ with gr.Blocks() as app:
|
|
| 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()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import io
|
| 3 |
|
| 4 |
def text_to_srt(text):
|
| 5 |
lines = text.split('\n')
|
|
|
|
| 18 |
def export_file(srt_content):
|
| 19 |
if srt_content.strip() == "":
|
| 20 |
return None
|
| 21 |
+
# Convert string to bytes and then to a file-like object
|
| 22 |
+
bytes_io = io.BytesIO(srt_content.encode('utf-8'))
|
| 23 |
+
return bytes_io, "output.srt"
|
| 24 |
|
| 25 |
with gr.Blocks() as app:
|
| 26 |
gr.Markdown("### Text to SRT Converter")
|
|
|
|
| 30 |
text_input.change(fn=text_to_srt, inputs=text_input, outputs=output)
|
| 31 |
export_button.click(fn=export_file, inputs=output, outputs=gr.File(label="Download SRT"))
|
| 32 |
|
| 33 |
+
app.launch()
|