arxivgpt kim commited on
Update app.py
Browse files
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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.
|
| 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 |
|