Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,11 @@ import time
|
|
4 |
import tempfile
|
5 |
from gradio_client import Client, handle_file
|
6 |
import gradio as gr
|
|
|
7 |
|
|
|
|
|
|
|
8 |
def main(url, parameters, progress=gr.Progress()):
|
9 |
try:
|
10 |
font_type, font_size, font_color, service, target, style, subject = parameters.split(',')
|
@@ -68,17 +72,11 @@ def main(url, parameters, progress=gr.Progress()):
|
|
68 |
output_video = job.outputs()[0]['video']
|
69 |
|
70 |
|
71 |
-
# Create temporary file
|
72 |
-
|
73 |
-
# Generate direct download link
|
74 |
-
base_url = os.environ.get('GRADIO_SERVER_NAME', 'http://localhost:7860')
|
75 |
-
download_url = f"{base_url}/file/{output_video}"
|
76 |
-
print(download_url)
|
77 |
|
78 |
finally:
|
79 |
video_client.close()
|
80 |
|
81 |
-
yield "پردازش کامل شد",
|
82 |
|
83 |
except Exception as e:
|
84 |
raise gr.Error(f"خطا در پردازش: {str(e)}")
|
@@ -90,7 +88,7 @@ with gr.Blocks() as demo:
|
|
90 |
video_file_input = gr.Text(label="لینک ویدئو")
|
91 |
parameters = gr.Text(label="پارامترهای زیرنویس (قلم، اندازه، رنگ)")
|
92 |
btn = gr.Button("ایجاد ویدئو جدید")
|
93 |
-
download_link = gr.
|
94 |
btn.click(
|
95 |
fn=main,
|
96 |
inputs=[video_file_input, parameters],
|
|
|
4 |
import tempfile
|
5 |
from gradio_client import Client, handle_file
|
6 |
import gradio as gr
|
7 |
+
from pathlib import Path
|
8 |
|
9 |
+
def download_file():
|
10 |
+
return gr.DownloadButton(visible=False)
|
11 |
+
|
12 |
def main(url, parameters, progress=gr.Progress()):
|
13 |
try:
|
14 |
font_type, font_size, font_color, service, target, style, subject = parameters.split(',')
|
|
|
72 |
output_video = job.outputs()[0]['video']
|
73 |
|
74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
|
76 |
finally:
|
77 |
video_client.close()
|
78 |
|
79 |
+
yield "پردازش کامل شد", gr.DownloadButton(value=output_video, visible=True)
|
80 |
|
81 |
except Exception as e:
|
82 |
raise gr.Error(f"خطا در پردازش: {str(e)}")
|
|
|
88 |
video_file_input = gr.Text(label="لینک ویدئو")
|
89 |
parameters = gr.Text(label="پارامترهای زیرنویس (قلم، اندازه، رنگ)")
|
90 |
btn = gr.Button("ایجاد ویدئو جدید")
|
91 |
+
download_link = gr.Text(label="لینک دانلود")
|
92 |
btn.click(
|
93 |
fn=main,
|
94 |
inputs=[video_file_input, parameters],
|