caokhoi91's picture
Update app.py
2eb935f verified
import gradio as gr
import requests
import os
API_URL = "https://fal.run/fal-ai/dia-tts"
headers = {"Authorization": f"Bearer {os.getenv('HF_TOKEN')}"}
def query(text):
payload = {"text": text}
response = requests.post(API_URL, headers=headers, json=payload)
if response.status_code != 200:
return f"❌ Error: {response.status_code} - {response.text}"
return response.json()
with gr.Blocks(fill_height=True) as demo:
with gr.Sidebar():
gr.Markdown("# Inference Provider")
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.")
gr.Markdown("πŸ”‘ Make sure your Hugging Face access token is available in the environment.")
with gr.Row():
inp = gr.Textbox(label="Input your text", placeholder="Type something...")
out = gr.Textbox(label="Response")
submit_btn = gr.Button("Submit")
submit_btn.click(fn=query, inputs=inp, outputs=out)
print("TOKEN LOADED:", os.getenv("HF_TOKEN"))
demo.launch()