Spaces:
Runtime error
Runtime error
Commit
Β·
5a686c9
1
Parent(s):
433ca1f
Update app.py
Browse files
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 = '
|
21 |
|
22 |
-
# κ°
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
fn=gradio_generate_status,
|
74 |
inputs=gr.Textbox(label="컨ν
μΈ ID"),
|
75 |
outputs=gr.HTML(label="λ€μ΄λ‘λ λ§ν¬ λ° λΉλμ€")
|
76 |
)
|
77 |
|
78 |
-
|
|
|
|
|
|
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()
|