Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,28 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
with gr.Blocks(fill_height=True) as demo:
|
| 4 |
with gr.Sidebar():
|
| 5 |
gr.Markdown("# Inference Provider")
|
| 6 |
gr.Markdown("This Space showcases the nari-labs/Dia-1.6B model, served by the fal-ai API. Sign in with your Hugging Face account to use this API.")
|
| 7 |
-
|
| 8 |
-
gr.load("models/nari-labs/Dia-1.6B", accept_token=button, provider="fal-ai")
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import requests
|
| 3 |
+
import os
|
| 4 |
+
|
| 5 |
+
API_URL = "https://fal.run/fal-ai/dia-tts"
|
| 6 |
+
headers = {"Authorization": f"Bearer {os.getenv('HF_TOKEN')}"}
|
| 7 |
+
|
| 8 |
+
def query(text):
|
| 9 |
+
payload = {"text": text}
|
| 10 |
+
response = requests.post(API_URL, headers=headers, json=payload)
|
| 11 |
+
if response.status_code != 200:
|
| 12 |
+
return f"❌ Error: {response.status_code} - {response.text}"
|
| 13 |
+
return response.json()
|
| 14 |
|
| 15 |
with gr.Blocks(fill_height=True) as demo:
|
| 16 |
with gr.Sidebar():
|
| 17 |
gr.Markdown("# Inference Provider")
|
| 18 |
gr.Markdown("This Space showcases the nari-labs/Dia-1.6B model, served by the fal-ai API. Sign in with your Hugging Face account to use this API.")
|
| 19 |
+
gr.Markdown("🔑 Make sure your Hugging Face access token is available in the environment.")
|
|
|
|
| 20 |
|
| 21 |
+
with gr.Row():
|
| 22 |
+
inp = gr.Textbox(label="Input your text", placeholder="Type something...")
|
| 23 |
+
out = gr.Textbox(label="Response")
|
| 24 |
+
|
| 25 |
+
submit_btn = gr.Button("Submit")
|
| 26 |
+
submit_btn.click(fn=query, inputs=inp, outputs=out)
|
| 27 |
+
|
| 28 |
+
demo.launch()
|