seawolf2357 commited on
Commit
9684c3a
Β·
1 Parent(s): 2e459e2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -8
app.py CHANGED
@@ -2,28 +2,34 @@ 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
 
 
2
  import requests
3
 
4
  API_KEY = "ZZUIQ4OZASNRQ8B8WYHNW"
5
+ API_URL = "https://api.fliki.ai/v1"
6
 
7
+ def generate_content(format, content, voice_id):
8
+ url = f"{API_URL}/generate"
9
+ payload = {
10
+ "format": format,
11
+ "scenes": [{"content": content, "voiceId": voice_id}],
12
+ # μΆ”κ°€ μ„€μ • ν•„μš”ν•œ 경우 여기에 μΆ”κ°€
13
+ }
14
  headers = {"Authorization": f"Bearer {API_KEY}"}
 
15
  response = requests.post(url, json=payload, headers=headers)
16
+
17
  if response.status_code == 200:
18
+ return response.json()['url']
19
  else:
20
  raise Exception(f"였λ₯˜ λ°œμƒ: {response.status_code}")
21
 
22
  with gr.Blocks() as demo:
23
  with gr.Row():
24
+ format_input = gr.Dropdown(choices=["video", "text-to-speech"], label="포맷 선택")
25
+ content_input = gr.Textbox(label="μ½˜ν…μΈ  μž…λ ₯")
26
+ voice_id_input = gr.Textbox(label="μŒμ„± ID μž…λ ₯")
27
  submit_button = gr.Button("생성")
28
  output = gr.Video(label="μƒμ„±λœ μ½˜ν…μΈ ")
29
 
30
  submit_button.click(
31
  generate_content,
32
+ inputs=[format_input, content_input, voice_id_input],
33
  outputs=output
34
  )
35