arxivgpt kim commited on
Commit
adf1016
ยท
verified ยท
1 Parent(s): 98447ea

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -40,20 +40,23 @@ def create_video(video_file_id, audio_file_id):
40
 
41
  headers = {"accept": "application/json", "x-api-key": API_KEY, "Content-Type": "application/json"}
42
 
43
- # API ํ˜ธ์ถœ
44
  response = requests.post(api_url, json=payload, headers=headers)
45
  if response.status_code in [200, 201]:
46
  job_id = response.json()["id"]
47
- # ์ƒํƒœ ํ™•์ธ ๋ฐ ์ตœ์ข… ๊ฒฐ๊ณผ ๋ฐ˜ํ™˜
48
  download_url, message = check_status_and_get_link(job_id)
49
- return job_id, download_url, message
 
 
 
 
 
50
  else:
51
  return "API ํ˜ธ์ถœ ์‹คํŒจ", None, None
52
 
53
  iface = gr.Interface(
54
  fn=create_video,
55
  inputs=[gr.Textbox(label="๋น„๋””์˜ค ํŒŒ์ผ์˜ Google Drive ID"), gr.Textbox(label="์˜ค๋””์˜ค ํŒŒ์ผ์˜ Google Drive ID")],
56
- outputs=[gr.Textbox(label="์ž‘์—… ID"), gr.Textbox(label="๋น„๋””์˜ค ๋‹ค์šด๋กœ๋“œ ๋งํฌ"), gr.Textbox(label="๋ฉ”์‹œ์ง€")],
57
  description="Google Drive ๊ณต์œ ๋œ mp4 ํŒŒ์ผ๊ณผ ์˜ค๋””์˜ค ํŒŒ์ผ์˜ ID๋ฅผ ์ž…๋ ฅํ•˜์—ฌ ๋น„๋””์˜ค๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค."
58
  )
59
 
 
40
 
41
  headers = {"accept": "application/json", "x-api-key": API_KEY, "Content-Type": "application/json"}
42
 
 
43
  response = requests.post(api_url, json=payload, headers=headers)
44
  if response.status_code in [200, 201]:
45
  job_id = response.json()["id"]
 
46
  download_url, message = check_status_and_get_link(job_id)
47
+ if download_url:
48
+ # HTML ์ฝ”๋“œ ์ƒ์„ฑ: ๋น„๋””์˜ค ์ž„๋ฒ ๋“œ ๋ฐ ๋‹ค์šด๋กœ๋“œ ๋งํฌ
49
+ html_code = f'<video width="640" height="360" controls><source src="{download_url}" type="video/mp4"></video><br><a href="{download_url}" target="_blank">๋‹ค์šด๋กœ๋“œ</a>'
50
+ return job_id, html_code, message
51
+ else:
52
+ return job_id, "๋น„๋””์˜ค ๋งํฌ๋ฅผ ๋ถˆ๋Ÿฌ์˜ฌ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.", message
53
  else:
54
  return "API ํ˜ธ์ถœ ์‹คํŒจ", None, None
55
 
56
  iface = gr.Interface(
57
  fn=create_video,
58
  inputs=[gr.Textbox(label="๋น„๋””์˜ค ํŒŒ์ผ์˜ Google Drive ID"), gr.Textbox(label="์˜ค๋””์˜ค ํŒŒ์ผ์˜ Google Drive ID")],
59
+ outputs=[gr.Textbox(label="์ž‘์—… ID"), gr.HTML(label="๋น„๋””์˜ค"), gr.Textbox(label="๋ฉ”์‹œ์ง€")],
60
  description="Google Drive ๊ณต์œ ๋œ mp4 ํŒŒ์ผ๊ณผ ์˜ค๋””์˜ค ํŒŒ์ผ์˜ ID๋ฅผ ์ž…๋ ฅํ•˜์—ฌ ๋น„๋””์˜ค๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค."
61
  )
62