akthangdz commited on
Commit
37a7c5f
·
1 Parent(s): f4ce634
Files changed (1) hide show
  1. app.py +11 -11
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 mp3 trong thư mục temp
10
- mp3_files = [f for f in os.listdir('temp') if f.endswith('.mp3')]
11
- if mp3_files:
12
- # Trả về đường dẫn đến file mp3 mới nhất
13
- latest_mp3 = os.path.join('temp', mp3_files[-1])
14
- return result.stdout, latest_mp3
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-Voice")
22
 
23
  with gr.Row():
24
- run_button = gr.Button("Chạy Text-to-Voice")
25
  output = gr.Textbox(label="Kết quả")
26
 
27
- # Thêm audio player
28
- audio_output = gr.Audio(label="File âm thanh đã tạo")
29
 
30
- run_button.click(fn=run_ttv, outputs=[output, audio_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__":