File size: 1,078 Bytes
fee22a7
311e978
 
 
 
 
 
 
 
 
 
 
 
fee22a7
 
 
 
 
311e978
fee22a7
311e978
 
 
 
 
 
2eb935f
 
ae84e80
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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()