arxivgpt kim commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,7 +7,7 @@ import os
|
|
| 7 |
API_KEY = os.getenv("API_KEY")
|
| 8 |
|
| 9 |
# μ€μ API μλν¬μΈνΈ μ£Όμ
|
| 10 |
-
api_url =
|
| 11 |
|
| 12 |
def check_status_and_get_link(job_id):
|
| 13 |
status_url = f"{api_url}/{job_id}"
|
|
@@ -35,7 +35,7 @@ def create_video(video_file_id, audio_file_id):
|
|
| 35 |
"synergize": True,
|
| 36 |
"maxCredits": None,
|
| 37 |
"webhookUrl": None,
|
| 38 |
-
"model": "sync-1"
|
| 39 |
}
|
| 40 |
|
| 41 |
headers = {"accept": "application/json", "x-api-key": API_KEY, "Content-Type": "application/json"}
|
|
@@ -45,9 +45,15 @@ def create_video(video_file_id, audio_file_id):
|
|
| 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'
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
else:
|
| 52 |
return job_id, "λΉλμ€ λ§ν¬λ₯Ό λΆλ¬μ¬ μ μμ΅λλ€.", message
|
| 53 |
else:
|
|
@@ -55,8 +61,15 @@ def create_video(video_file_id, audio_file_id):
|
|
| 55 |
|
| 56 |
iface = gr.Interface(
|
| 57 |
fn=create_video,
|
| 58 |
-
inputs=[
|
| 59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
description="Google Drive 곡μ λ mp4 νμΌκ³Ό μ€λμ€ νμΌμ IDλ₯Ό μ
λ ₯νμ¬ λΉλμ€λ₯Ό μμ±ν©λλ€."
|
| 61 |
)
|
| 62 |
|
|
|
|
| 7 |
API_KEY = os.getenv("API_KEY")
|
| 8 |
|
| 9 |
# μ€μ API μλν¬μΈνΈ μ£Όμ
|
| 10 |
+
api_url = os.getenv("api_url")
|
| 11 |
|
| 12 |
def check_status_and_get_link(job_id):
|
| 13 |
status_url = f"{api_url}/{job_id}"
|
|
|
|
| 35 |
"synergize": True,
|
| 36 |
"maxCredits": None,
|
| 37 |
"webhookUrl": None,
|
| 38 |
+
"model": "sync-1.5.1-beta"
|
| 39 |
}
|
| 40 |
|
| 41 |
headers = {"accept": "application/json", "x-api-key": API_KEY, "Content-Type": "application/json"}
|
|
|
|
| 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'''
|
| 50 |
+
<video width="640" height="360" controls>
|
| 51 |
+
<source src="{download_url}" type="video/mp4">
|
| 52 |
+
</video>
|
| 53 |
+
<br>
|
| 54 |
+
<button onclick="window.location.href='{download_url}'">λ€μ΄λ‘λ</button>
|
| 55 |
+
'''
|
| 56 |
+
return job_id, html_code, "λΉλμ€κ° μ±κ³΅μ μΌλ‘ μμ±λμμ΅λλ€."
|
| 57 |
else:
|
| 58 |
return job_id, "λΉλμ€ λ§ν¬λ₯Ό λΆλ¬μ¬ μ μμ΅λλ€.", message
|
| 59 |
else:
|
|
|
|
| 61 |
|
| 62 |
iface = gr.Interface(
|
| 63 |
fn=create_video,
|
| 64 |
+
inputs=[
|
| 65 |
+
gr.Textbox(label="λΉλμ€ νμΌμ Google Drive ID"),
|
| 66 |
+
gr.Textbox(label="μ€λμ€ νμΌμ Google Drive ID")
|
| 67 |
+
],
|
| 68 |
+
outputs=[
|
| 69 |
+
gr.Textbox(label="μμ
ID"),
|
| 70 |
+
gr.HTML(label="λΉλμ€"),
|
| 71 |
+
gr.Textbox(label="λ©μμ§")
|
| 72 |
+
],
|
| 73 |
description="Google Drive 곡μ λ mp4 νμΌκ³Ό μ€λμ€ νμΌμ IDλ₯Ό μ
λ ₯νμ¬ λΉλμ€λ₯Ό μμ±ν©λλ€."
|
| 74 |
)
|
| 75 |
|