arxivgpt kim commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,8 +5,9 @@ import os
|
|
| 5 |
|
| 6 |
# 환경 변수에서 API 키를 읽어옵니다.
|
| 7 |
API_KEY = os.getenv("API_KEY")
|
|
|
|
| 8 |
# 실제 API 엔드포인트 주소
|
| 9 |
-
api_url = os.getenv("
|
| 10 |
|
| 11 |
def check_status_and_get_link(job_id):
|
| 12 |
status_url = f"{api_url}/{job_id}"
|
|
@@ -22,7 +23,7 @@ def check_status_and_get_link(job_id):
|
|
| 22 |
return None, "비디오 생성 실패."
|
| 23 |
else:
|
| 24 |
return None, "상태 확인 중 오류 발생."
|
| 25 |
-
time.sleep(10)
|
| 26 |
|
| 27 |
def create_video(video_file_id, audio_file_id):
|
| 28 |
video_download_link = f"https://drive.google.com/uc?export=download&id={video_file_id}"
|
|
@@ -44,6 +45,7 @@ def create_video(video_file_id, audio_file_id):
|
|
| 44 |
job_id = response.json()["id"]
|
| 45 |
download_url, message = check_status_and_get_link(job_id)
|
| 46 |
if download_url:
|
|
|
|
| 47 |
html_code = f'''
|
| 48 |
<video width="640" height="360" controls>
|
| 49 |
<source src="{download_url}" type="video/mp4">
|
|
@@ -68,9 +70,8 @@ iface = gr.Interface(
|
|
| 68 |
gr.HTML(label="비디오"),
|
| 69 |
gr.Textbox(label="메시지")
|
| 70 |
],
|
| 71 |
-
title="혜자 페이스 프로젝트", # 타이틀 삽입
|
| 72 |
description="Google Drive 공유된 mp4 파일과 오디오 파일의 ID를 입력하여 비디오를 생성합니다."
|
| 73 |
)
|
| 74 |
|
| 75 |
# Gradio 앱 실행
|
| 76 |
-
iface.launch()
|
|
|
|
| 5 |
|
| 6 |
# 환경 변수에서 API 키를 읽어옵니다.
|
| 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}"
|
|
|
|
| 23 |
return None, "비디오 생성 실패."
|
| 24 |
else:
|
| 25 |
return None, "상태 확인 중 오류 발생."
|
| 26 |
+
time.sleep(10) # 10초 간격으로 상태 체크
|
| 27 |
|
| 28 |
def create_video(video_file_id, audio_file_id):
|
| 29 |
video_download_link = f"https://drive.google.com/uc?export=download&id={video_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 |
<video width="640" height="360" controls>
|
| 51 |
<source src="{download_url}" type="video/mp4">
|
|
|
|
| 70 |
gr.HTML(label="비디오"),
|
| 71 |
gr.Textbox(label="메시지")
|
| 72 |
],
|
|
|
|
| 73 |
description="Google Drive 공유된 mp4 파일과 오디오 파일의 ID를 입력하여 비디오를 생성합니다."
|
| 74 |
)
|
| 75 |
|
| 76 |
# Gradio 앱 실행
|
| 77 |
+
iface.launch()
|