Spaces:
Sleeping
Sleeping
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')
|
@@ -12,12 +13,16 @@ def text_to_srt(text):
|
|
12 |
srt_content += f"{i+1}\n{start.replace('.', ',')} --> {end.replace('.', ',')}\n{content.strip()}\n\n"
|
13 |
except ValueError:
|
14 |
continue # Skip lines that don't match the expected format
|
15 |
-
|
|
|
|
|
|
|
|
|
16 |
|
17 |
with gr.Blocks() as app:
|
18 |
gr.Markdown("### Text to SRT Converter")
|
19 |
text_input = gr.TextArea(label="Enter text from Whisper Jax Space")
|
20 |
-
output = gr.
|
21 |
text_input.change(fn=text_to_srt, inputs=text_input, outputs=output)
|
22 |
|
23 |
app.launch(share=True)
|
|
|
1 |
import gradio as gr
|
2 |
+
import os
|
3 |
|
4 |
def text_to_srt(text):
|
5 |
lines = text.split('\n')
|
|
|
13 |
srt_content += f"{i+1}\n{start.replace('.', ',')} --> {end.replace('.', ',')}\n{content.strip()}\n\n"
|
14 |
except ValueError:
|
15 |
continue # Skip lines that don't match the expected format
|
16 |
+
# Save SRT content to a temporary file
|
17 |
+
temp_file_path = '/tmp/output.srt'
|
18 |
+
with open(temp_file_path, 'w') as file:
|
19 |
+
file.write(srt_content)
|
20 |
+
return temp_file_path
|
21 |
|
22 |
with gr.Blocks() as app:
|
23 |
gr.Markdown("### Text to SRT Converter")
|
24 |
text_input = gr.TextArea(label="Enter text from Whisper Jax Space")
|
25 |
+
output = gr.File(label="Download SRT File", file_count="single") # Change output to a File component
|
26 |
text_input.change(fn=text_to_srt, inputs=text_input, outputs=output)
|
27 |
|
28 |
app.launch(share=True)
|