Spaces:
Build error
Build error
Commit
Β·
2e459e2
1
Parent(s):
993c6c8
Update app.py
Browse files
app.py
CHANGED
@@ -1,44 +1,30 @@
|
|
1 |
import gradio as gr
|
2 |
import requests
|
3 |
|
4 |
-
# API ν€ μ€μ
|
5 |
API_KEY = "ZZUIQ4OZASNRQ8B8WYHNW"
|
6 |
|
7 |
-
def
|
8 |
-
|
9 |
-
|
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()[
|
23 |
else:
|
24 |
-
raise Exception(f"μ€λ₯
|
25 |
|
26 |
-
# Gradio μΈν°νμ΄μ€ μ μ
|
27 |
with gr.Blocks() as demo:
|
28 |
with gr.Row():
|
29 |
-
|
30 |
-
|
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 |
-
|
39 |
-
inputs=[
|
40 |
-
outputs=
|
41 |
)
|
42 |
|
43 |
-
|
44 |
-
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
import requests
|
3 |
|
|
|
4 |
API_KEY = "ZZUIQ4OZASNRQ8B8WYHNW"
|
5 |
|
6 |
+
def generate_content(text, content_type):
|
7 |
+
url = f"https://api.fliki.ai/v1/generate/{content_type}"
|
8 |
+
payload = {"text": text}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
headers = {"Authorization": f"Bearer {API_KEY}"}
|
10 |
+
|
11 |
response = requests.post(url, json=payload, headers=headers)
|
|
|
12 |
if response.status_code == 200:
|
13 |
+
return response.json()['url'] # λΉλμ€ λλ μ€λμ€ URL λ°ν
|
14 |
else:
|
15 |
+
raise Exception(f"μ€λ₯ λ°μ: {response.status_code}")
|
16 |
|
|
|
17 |
with gr.Blocks() as demo:
|
18 |
with gr.Row():
|
19 |
+
text_input = gr.Textbox(label="ν
μ€νΈ μ
λ ₯")
|
20 |
+
content_type_input = gr.Dropdown(choices=["text-to-speech", "text-to-video"], label="μ½ν
μΈ μ ν")
|
|
|
|
|
21 |
submit_button = gr.Button("μμ±")
|
22 |
+
output = gr.Video(label="μμ±λ μ½ν
μΈ ")
|
|
|
23 |
|
24 |
submit_button.click(
|
25 |
+
generate_content,
|
26 |
+
inputs=[text_input, content_type_input],
|
27 |
+
outputs=output
|
28 |
)
|
29 |
|
30 |
+
demo.launch()
|
|