seawolf2357 commited on
Commit
5a686c9
Β·
1 Parent(s): 433ca1f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -9
app.py CHANGED
@@ -14,19 +14,25 @@ def set_header():
14
  }
15
  return header
16
 
17
- # λΉ„λ””μ˜€ λ˜λŠ” μ˜€λ””μ˜€ 컨텐츠 μƒμ„±ν•˜λŠ” ν•¨μˆ˜.
18
- def generate_contents(user_content, brand_name):
19
  url = API_HOME + END_GENERATE
20
- VOICE_ID = '65934ac2bc02ab1c006755fa' # Korean, Korea, Wolf Sea
21
 
22
- # 각 λ¬Έμž₯을 λ³„λ„μ˜ scene으둜 처리
23
- scenes = [{"content": line, "voiceId": VOICE_ID} for line in user_content.split('\n') if line.strip()]
24
 
25
  payload = {
26
  "format": "video", # video | audio
27
  "scenes": scenes,
28
  "settings": {
29
- # μ„€μ •λ“€...
 
 
 
 
 
 
30
  },
31
  "backgroundMusicKeywords": "happy, lofi, beats"
32
  }
@@ -39,7 +45,7 @@ def generate_contents(user_content, brand_name):
39
  else:
40
  return 'FAILED'
41
 
42
- # 컨텐츠 생성 μƒνƒœλ₯Ό ν™•μΈν•˜λŠ” ν•¨μˆ˜.
43
  def generate_status(content_id):
44
  url = API_HOME + END_STATUS
45
  payload = {"id": content_id}
@@ -59,6 +65,9 @@ def generate_status(content_id):
59
  return 'FAILED'
60
 
61
  # Gradio μΈν„°νŽ˜μ΄μŠ€ ν•¨μˆ˜
 
 
 
62
  def gradio_generate_status(content_id):
63
  download_url = generate_status(content_id)
64
  if download_url != 'FAILED':
@@ -69,10 +78,24 @@ def gradio_generate_status(content_id):
69
  else:
70
  return "컨텐츠 생성 μ‹€νŒ¨ λ˜λŠ” IDκ°€ 잘λͺ»λ˜μ—ˆμŠ΅λ‹ˆλ‹€."
71
 
72
- status_iface = gr.Interface(
 
 
 
 
 
 
 
 
 
 
 
 
73
  fn=gradio_generate_status,
74
  inputs=gr.Textbox(label="컨텐츠 ID"),
75
  outputs=gr.HTML(label="λ‹€μš΄λ‘œλ“œ 링크 및 λΉ„λ””μ˜€")
76
  )
77
 
78
- status_iface.launch()
 
 
 
14
  }
15
  return header
16
 
17
+ # λΉ„λ””μ˜€ λ˜λŠ” μ˜€λ””μ˜€ 컨텐츠 μƒμ„±ν•˜λŠ” ν•¨μˆ˜
18
+ def generate_contents(user_content, brand_name, aspect_ratio='landscape'):
19
  url = API_HOME + END_GENERATE
20
+ VOICE_ID = '64ea14306a00ac991dcb8a3f' # Korean, Korea, Wolf Sea
21
 
22
+ # λ©€ν‹° 라인 ν…μŠ€νŠΈλ₯Ό λΆ„λ¦¬ν•˜μ—¬ 각 쀄을 λ³„λ„μ˜ μ”¬μœΌλ‘œ 처리
23
+ scenes = [{"content": line.strip(), "voiceId": VOICE_ID} for line in user_content.split('\n') if line.strip()]
24
 
25
  payload = {
26
  "format": "video", # video | audio
27
  "scenes": scenes,
28
  "settings": {
29
+ 'aspectRatio': aspect_ratio,
30
+ 'subtitle': {
31
+ 'fontColor': 'yellow',
32
+ 'backgroundColor': 'black',
33
+ 'placement': 'bottom',
34
+ 'display': 'phrase',
35
+ },
36
  },
37
  "backgroundMusicKeywords": "happy, lofi, beats"
38
  }
 
45
  else:
46
  return 'FAILED'
47
 
48
+ # 컨텐츠 생성 μƒνƒœλ₯Ό ν™•μΈν•˜λŠ” ν•¨μˆ˜
49
  def generate_status(content_id):
50
  url = API_HOME + END_STATUS
51
  payload = {"id": content_id}
 
65
  return 'FAILED'
66
 
67
  # Gradio μΈν„°νŽ˜μ΄μŠ€ ν•¨μˆ˜
68
+ def gradio_generate_contents(user_content, brand_name, aspect_ratio):
69
+ return generate_contents(user_content, brand_name, aspect_ratio)
70
+
71
  def gradio_generate_status(content_id):
72
  download_url = generate_status(content_id)
73
  if download_url != 'FAILED':
 
78
  else:
79
  return "컨텐츠 생성 μ‹€νŒ¨ λ˜λŠ” IDκ°€ 잘λͺ»λ˜μ—ˆμŠ΅λ‹ˆλ‹€."
80
 
81
+ # 컨텐츠 생성 μΈν„°νŽ˜μ΄μŠ€
82
+ iface_create = gr.Interface(
83
+ fn=gradio_generate_contents,
84
+ inputs=[
85
+ gr.TextArea(label="컨텐츠 ν…μŠ€νŠΈ"),
86
+ gr.Textbox(label="λΈŒλžœλ“œλͺ…"),
87
+ gr.Dropdown(label="ν™”λ©΄ λΉ„μœ¨", choices=['portrait', 'square', 'landscape'], value='landscape')
88
+ ],
89
+ outputs=gr.Textbox(label="컨텐츠 ID")
90
+ )
91
+
92
+ # μƒνƒœ 확인 및 λΉ„λ””μ˜€ λ‹€μš΄λ‘œλ“œ μΈν„°νŽ˜μ΄μŠ€
93
+ iface_status = gr.Interface(
94
  fn=gradio_generate_status,
95
  inputs=gr.Textbox(label="컨텐츠 ID"),
96
  outputs=gr.HTML(label="λ‹€μš΄λ‘œλ“œ 링크 및 λΉ„λ””μ˜€")
97
  )
98
 
99
+ # 두 μΈν„°νŽ˜μ΄μŠ€λ₯Ό νƒ­μœΌλ‘œ ꡬ성
100
+ iface_combined = gr.TabbedInterface([iface_create, iface_status], ["컨텐츠 생성", "μƒνƒœ 확인 및 λ‹€μš΄λ‘œλ“œ"])
101
+ iface_combined.launch()