arxivgpt kim commited on
Commit
765bc14
·
verified ·
1 Parent(s): 63e8782

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -24
app.py CHANGED
@@ -2,8 +2,6 @@ import gradio as gr
2
  import requests
3
  import time
4
  import os
5
- import re
6
-
7
 
8
  # 환경 변수에서 API 키를 읽어옵니다.
9
  api_key = os.getenv("API_KEY")
@@ -11,26 +9,10 @@ api_key = os.getenv("API_KEY")
11
  # 여기에 실제 API 엔드포인트 주소를 할당합니다.
12
  api_url = "https://api.synclabs.so/video"
13
 
14
- def convert_google_drive_link(share_link):
15
- patterns = [
16
- r"/file/d/([a-zA-Z0-9_-]+)",
17
- r"open\?id=([a-zA-Z0-9_-]+)",
18
- r"uc\?id=([a-zA-Z0-9_-]+)&export=download"
19
- ]
20
-
21
- for pattern in patterns:
22
- match = re.search(pattern, share_link)
23
- if match:
24
- file_id = match.group(1)
25
- return f"https://drive.google.com/uc?export=download&id={file_id}"
26
-
27
- # 매치되는 패턴이 없는 경우
28
- raise ValueError("Google Drive 공유 링크에서 파일 ID를 추출할 수 없습니다. 링크 형식을 확인해주세요.")
29
-
30
-
31
- def create_video(video_share_link, audio_share_link):
32
- video_download_link = convert_google_drive_link(video_share_link)
33
- audio_download_link = convert_google_drive_link(audio_share_link)
34
 
35
  payload = {
36
  "audioUrl": audio_download_link,
@@ -67,9 +49,12 @@ def create_video(video_share_link, audio_share_link):
67
 
68
  iface = gr.Interface(
69
  fn=create_video,
70
- inputs=[gr.Textbox(label="비디오 파일의 구글 드라이브 공유 링크"), gr.Textbox(label="오디오 파일의 구글 드라이브 공유 링크")],
 
 
 
71
  outputs=gr.Textbox(label="생성된 비디오 다운로드 링크"),
72
- description="구글 드라이브 공유된 mp4 파일과 오디오 파일 합성하여 비디오를 생성합니다."
73
  )
74
 
75
  # Gradio 앱 실행
 
2
  import requests
3
  import time
4
  import os
 
 
5
 
6
  # 환경 변수에서 API 키를 읽어옵니다.
7
  api_key = os.getenv("API_KEY")
 
9
  # 여기에 실제 API 엔드포인트 주소를 할당합니다.
10
  api_url = "https://api.synclabs.so/video"
11
 
12
+ def create_video(video_file_id, audio_file_id):
13
+ # 사용자로부터 입력받은 파일 ID를 기반으로 다운로드 링크 생성
14
+ video_download_link = f"https://drive.google.com/uc?export=download&id={video_file_id}"
15
+ audio_download_link = f"https://drive.google.com/uc?export=download&id={audio_file_id}"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
  payload = {
18
  "audioUrl": audio_download_link,
 
49
 
50
  iface = gr.Interface(
51
  fn=create_video,
52
+ inputs=[
53
+ gr.Textbox(label="비디오 파일의 Google Drive ID"),
54
+ gr.Textbox(label="오디오 파일의 Google Drive ID")
55
+ ],
56
  outputs=gr.Textbox(label="생성된 비디오 다운로드 링크"),
57
+ description="Google Drive 공유된 mp4 파일과 오디오 파일 ID를 입력하여 비디오를 생성합니다."
58
  )
59
 
60
  # Gradio 앱 실행