Spaces:
Sleeping
Sleeping
Trung commited on
Commit ·
1f493fd
1
Parent(s): 427c254
update
Browse files
app.py
CHANGED
|
@@ -1,28 +1,41 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import os
|
| 3 |
-
from huggingface_hub import get_token
|
| 4 |
|
| 5 |
-
|
| 6 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
| 7 |
-
PRIVATE_SPACE_ID = "okeysir/tts-sync-prototype-backend"
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
-
|
|
|
|
|
|
| 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()
|