seawolf2357 commited on
Commit
5e1e62f
Β·
1 Parent(s): 9684c3a

Update app.py

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