Spaces:
Build error
Build error
Commit
ยท
993c6c8
1
Parent(s):
01d4338
Update app.py
Browse files
app.py
CHANGED
@@ -1,84 +1,44 @@
|
|
1 |
import gradio as gr
|
2 |
import requests
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
"๊น์ ์": "์๋
ํ์ธ์, ์ํด ๋ณต ๋ง์ด ๋ฐ์ผ์๊ธธ ๊ธฐ์ํฉ๋๋ค.",
|
13 |
-
"๋
ธ๋ฌดํ": "์๋
ํ์ธ์, ์ํด ๋ณต ๋ง์ด ๋ฐ์ผ์๊ธธ ๊ธฐ์ํฉ๋๋ค.",
|
14 |
-
"๊ถ์": "์๋
ํ์ธ์, ๋ฏธ๋ฅต์ ๊ฐ๋ฅด์นจ์, ์ด๋ง๋ ๋ฐ๋ฉํ์ด๋๋ผ.",
|
15 |
-
"์ค์์ด": "์๋
ํ์ธ์, ์ํด ๋ณต ๋ง์ด ๋ฐ์ผ์๊ธธ ๊ธฐ์ํฉ๋๋ค."
|
16 |
-
}
|
17 |
-
|
18 |
-
MAX_CHARS = 100
|
19 |
-
if not text:
|
20 |
-
text = default_examples[voice_name] # ์ฌ์ฉ์ ์
๋ ฅ์ด ์์ผ๋ฉด ๊ธฐ๋ณธ ์์ ์ฌ์ฉ
|
21 |
-
elif len(text) > MAX_CHARS:
|
22 |
-
text = text[:MAX_CHARS] # ์ต๋ ๊ธ์์๋ก ํ
์คํธ ์๋ฅด๊ธฐ
|
23 |
-
|
24 |
-
voices = {
|
25 |
-
"๋จ์ฑAI": "6uQD2RqeSgIey9LVBafG",
|
26 |
-
"์ฌ์ฑAI": "jeuEgCxtyEYkC3zsQODy",
|
27 |
-
"ํธ๋ผํ": "nP4xQZkEwzlvgutdc3xM",
|
28 |
-
"์ฐจ์น์": "SKwm0HLYsVDCM2ruvw2p",
|
29 |
-
"๊น์ ์": "YPWL3nQPzBN1XaiZF4aj",
|
30 |
-
"๋
ธ๋ฌดํ": "6JdivX36i1eJ3LqLmvwH",
|
31 |
-
"๊ถ์": "4kFrgJPCTjA6DyPM5Gr5",
|
32 |
-
"์ค์์ด": "Qrf03Q67kRgpFlj9fto3"
|
33 |
-
}
|
34 |
-
voice_id = voices[voice_name]
|
35 |
-
url = f"https://api.elevenlabs.io/v1/text-to-speech/{voice_id}"
|
36 |
-
model_id = "eleven_multilingual_v2"
|
37 |
payload = {
|
38 |
-
"
|
39 |
-
"
|
40 |
-
"
|
41 |
-
|
42 |
-
"stability": 0.5,
|
43 |
-
"style": 0,
|
44 |
-
"use_speaker_boost": True
|
45 |
-
}
|
46 |
-
}
|
47 |
-
headers = {
|
48 |
-
"Content-Type": "application/json",
|
49 |
-
"xi-api-key": "c5fb99a2b25402f104d246379bcf819a"
|
50 |
}
|
51 |
-
|
52 |
-
response = requests.post(url, json=payload, headers=headers
|
53 |
-
|
54 |
if response.status_code == 200:
|
55 |
-
|
56 |
-
for chunk in response.iter_content(chunk_size=CHUNK_SIZE):
|
57 |
-
chunks.append(chunk)
|
58 |
-
return b''.join(chunks)
|
59 |
else:
|
60 |
raise Exception(f"์ค๋ฅ ๋ฐ์. ์ํ ์ฝ๋: {response.status_code}")
|
61 |
|
62 |
-
CHUNK_SIZE = 1024
|
63 |
-
|
64 |
-
|
65 |
# Gradio ์ธํฐํ์ด์ค ์ ์
|
66 |
with gr.Blocks() as demo:
|
67 |
-
gr.
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
|
76 |
submit_button.click(
|
77 |
-
fn=
|
78 |
-
inputs=[
|
79 |
-
outputs=
|
80 |
)
|
81 |
|
82 |
-
|
83 |
if __name__ == "__main__":
|
84 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
import requests
|
3 |
|
4 |
+
# API ํค ์ค์
|
5 |
+
API_KEY = "ZZUIQ4OZASNRQ8B8WYHNW"
|
6 |
+
|
7 |
+
def generate_video(keyword, voice_actor, content_type, style):
|
8 |
+
# Fliki API์ ๋น๋์ค ์์ฑ ์์ฒญ์ ๋ณด๋ด๋ ์ฝ๋
|
9 |
+
# ์ด ๋ถ๋ถ์ Fliki API ๋ฌธ์์ ๋ฐ๋ผ ์ ์ ํ๊ฒ ๊ตฌํํด์ผ ํฉ๋๋ค.
|
10 |
+
# ์์:
|
11 |
+
url = "https://api.fliki.ai/v1/generate/video"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
payload = {
|
13 |
+
"keyword": keyword,
|
14 |
+
"voice_actor": voice_actor,
|
15 |
+
"content_type": content_type,
|
16 |
+
"style": style
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
}
|
18 |
+
headers = {"Authorization": f"Bearer {API_KEY}"}
|
19 |
+
response = requests.post(url, json=payload, headers=headers)
|
20 |
+
|
21 |
if response.status_code == 200:
|
22 |
+
return response.json()["video_url"] # ๋น๋์ค URL ๋ฐํ
|
|
|
|
|
|
|
23 |
else:
|
24 |
raise Exception(f"์ค๋ฅ ๋ฐ์. ์ํ ์ฝ๋: {response.status_code}")
|
25 |
|
|
|
|
|
|
|
26 |
# Gradio ์ธํฐํ์ด์ค ์ ์
|
27 |
with gr.Blocks() as demo:
|
28 |
+
with gr.Row():
|
29 |
+
keyword_input = gr.Textbox(label="ํค์๋ ์
๋ ฅ")
|
30 |
+
voice_actor_input = gr.Dropdown(choices=["์ฑ์ฐ1", "์ฑ์ฐ2", "์ฑ์ฐ3"], label="์ฑ์ฐ ์ ํ")
|
31 |
+
content_type_input = gr.Radio(choices=["์ด๋ฏธ์ง", "๋น๋์ค"], label="์ฝํ
์ธ ์ ํ")
|
32 |
+
style_input = gr.Dropdown(choices=["์คํ์ผ1", "์คํ์ผ2", "์คํ์ผ3"], label="์คํ์ผ ์ ํ")
|
33 |
+
submit_button = gr.Button("์์ฑ")
|
34 |
+
|
35 |
+
video_output = gr.Video(label="์์ฑ๋ ๋น๋์ค")
|
36 |
|
37 |
submit_button.click(
|
38 |
+
fn=generate_video,
|
39 |
+
inputs=[keyword_input, voice_actor_input, content_type_input, style_input],
|
40 |
+
outputs=video_output
|
41 |
)
|
42 |
|
|
|
43 |
if __name__ == "__main__":
|
44 |
demo.launch()
|