Spaces:
Running
Running
main
Browse files
app.py
CHANGED
@@ -6,28 +6,28 @@ def run_ttv():
|
|
6 |
try:
|
7 |
result = subprocess.run(['python', 'ttv.py'], capture_output=True, text=True)
|
8 |
|
9 |
-
# Lấy danh sách file
|
10 |
-
|
11 |
-
if
|
12 |
-
# Trả về đường dẫn đến file
|
13 |
-
|
14 |
-
return result.stdout,
|
15 |
return result.stdout, None
|
16 |
except Exception as e:
|
17 |
return f"Có lỗi xảy ra: {str(e)}", None
|
18 |
|
19 |
# Tạo giao diện
|
20 |
with gr.Blocks() as demo:
|
21 |
-
gr.Markdown("# Ứng dụng Text-to-
|
22 |
|
23 |
with gr.Row():
|
24 |
-
run_button = gr.Button("Chạy Text-to-
|
25 |
output = gr.Textbox(label="Kết quả")
|
26 |
|
27 |
-
#
|
28 |
-
|
29 |
|
30 |
-
run_button.click(fn=run_ttv, outputs=[output,
|
31 |
|
32 |
# Chạy ứng dụng
|
33 |
if __name__ == "__main__":
|
|
|
6 |
try:
|
7 |
result = subprocess.run(['python', 'ttv.py'], capture_output=True, text=True)
|
8 |
|
9 |
+
# Lấy danh sách file video trong thư mục temp
|
10 |
+
video_files = [f for f in os.listdir('temp') if f.endswith(('.mp4', '.avi', '.mov'))]
|
11 |
+
if video_files:
|
12 |
+
# Trả về đường dẫn đến file video mới nhất
|
13 |
+
latest_video = os.path.join('temp', video_files[-1])
|
14 |
+
return result.stdout, latest_video
|
15 |
return result.stdout, None
|
16 |
except Exception as e:
|
17 |
return f"Có lỗi xảy ra: {str(e)}", None
|
18 |
|
19 |
# Tạo giao diện
|
20 |
with gr.Blocks() as demo:
|
21 |
+
gr.Markdown("# Ứng dụng Text-to-Video")
|
22 |
|
23 |
with gr.Row():
|
24 |
+
run_button = gr.Button("Chạy Text-to-Video")
|
25 |
output = gr.Textbox(label="Kết quả")
|
26 |
|
27 |
+
# Thay đổi từ Audio sang Video
|
28 |
+
video_output = gr.Video(label="File video đã tạo")
|
29 |
|
30 |
+
run_button.click(fn=run_ttv, outputs=[output, video_output])
|
31 |
|
32 |
# Chạy ứng dụng
|
33 |
if __name__ == "__main__":
|