Trung commited on
Commit
1f493fd
·
1 Parent(s): 427c254
Files changed (1) hide show
  1. app.py +35 -22
app.py CHANGED
@@ -1,28 +1,41 @@
1
  import gradio as gr
2
  import os
3
- from huggingface_hub import get_token
4
 
5
- # Get your Hugging Face token
6
  HF_TOKEN = os.environ.get("HF_TOKEN")
7
- PRIVATE_SPACE_ID = "okeysir/tts-sync-prototype-backend"
8
 
9
- # Create an app with custom HTML
10
- with gr.Blocks() as demo:
11
- gr.HTML(f'''
12
- <div style="display: flex; flex-direction: column; width: 100%; height: 800px;">
13
- <h1>Groq Chat Interface</h1>
14
- <p>Powered by Groq API and hosted on Hugging Face Spaces</p>
15
- <div style="flex-grow: 1; width: 100%;">
16
- <iframe
17
- src="https://huggingface.co/spaces/{PRIVATE_SPACE_ID}?token={HF_TOKEN}"
18
- width="100%"
19
- height="100%"
20
- frameborder="0"
21
- style="border: none; min-height: 700px;"
22
- allow="camera;microphone">
23
- </iframe>
24
- </div>
25
- </div>
26
- ''')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
- demo.launch()
 
 
1
  import gradio as gr
2
  import os
 
3
 
4
+
5
  HF_TOKEN = os.environ.get("HF_TOKEN")
 
6
 
7
+ def main():
8
+ # Your private space ID
9
+ PRIVATE_SPACE_ID = "okeysir/tts-sync-prototype-backend"
10
+
11
+ # Create a header for your public app
12
+ with gr.Blocks() as demo:
13
+
14
+ # Load from private space using the correct syntax
15
+ try:
16
+ app = gr.load(
17
+ name=PRIVATE_SPACE_ID,
18
+ src="spaces",
19
+ token=HF_TOKEN
20
+ )
21
+ # Embed the loaded app
22
+ # app.render()
23
+
24
+ except Exception as e:
25
+ gr.Markdown(f"""
26
+ ## Error loading application
27
+
28
+ There was an error connecting to the backend service. This could be due to:
29
+ - The backend service is not running
30
+ - Authentication issues with the private space
31
+ - Network connectivity problems
32
+
33
+ Please contact the administrator if this problem persists.
34
+ """)
35
+ gr.Markdown(f"Technical details (for administrators): {str(e)}")
36
+
37
+ # Launch the app
38
+ demo.launch()
39
 
40
+ if __name__ == "__main__":
41
+ main()