Spaces:
Sleeping
Sleeping
fix: error frpc
Browse files- gradio_app.py +11 -22
gradio_app.py
CHANGED
@@ -23,25 +23,29 @@ from notebook_lm_kokoro import (
|
|
23 |
KPipeline,
|
24 |
)
|
25 |
|
|
|
|
|
|
|
26 |
os.environ["HF_HOME"] = "/tmp/huggingface"
|
27 |
os.environ["TRANSFORMERS_CACHE"] = "/tmp/huggingface/transformers"
|
28 |
os.environ["XDG_CACHE_HOME"] = "/tmp/huggingface"
|
29 |
os.environ["TORCH_HOME"] = "/tmp/torch"
|
30 |
os.environ["MOSHI_CACHE_DIR"] = "/tmp/moshi"
|
31 |
|
|
|
32 |
warnings.filterwarnings("ignore")
|
33 |
NUM_WORKERS = multiprocessing.cpu_count()
|
34 |
|
35 |
-
|
36 |
def ensure_gradio_frpc():
|
37 |
"""
|
38 |
-
Ensures the frpc binary is present in the
|
|
|
39 |
"""
|
40 |
-
|
41 |
-
|
42 |
-
os.makedirs(
|
43 |
|
44 |
-
frpc_file = os.path.join(
|
45 |
|
46 |
if not os.path.exists(frpc_file):
|
47 |
print(f"[INFO] Downloading frpc binary to: {frpc_file}")
|
@@ -53,21 +57,7 @@ def ensure_gradio_frpc():
|
|
53 |
except Exception as e:
|
54 |
print(f"[ERROR] Failed to download frpc binary: {e}")
|
55 |
else:
|
56 |
-
print("[INFO] frpc binary already exists.")
|
57 |
-
|
58 |
-
def symlink_frpc_to_expected_location():
|
59 |
-
expected_dir = os.path.expanduser("~/.cache/huggingface/gradio/frpc")
|
60 |
-
actual_dir = "/tmp/huggingface/gradio/frpc"
|
61 |
-
os.makedirs(os.path.dirname(expected_dir), exist_ok=True)
|
62 |
-
|
63 |
-
try:
|
64 |
-
if not os.path.exists(expected_dir):
|
65 |
-
os.symlink(actual_dir, expected_dir)
|
66 |
-
print(f"[SYMLINK] Linked {actual_dir} → {expected_dir}")
|
67 |
-
else:
|
68 |
-
print(f"[SYMLINK] Already exists: {expected_dir}")
|
69 |
-
except Exception as e:
|
70 |
-
print(f"[ERROR] Failed to symlink: {e}")
|
71 |
|
72 |
def process_segment(entry_and_voice_map):
|
73 |
entry, voice_map = entry_and_voice_map
|
@@ -229,6 +219,5 @@ def create_gradio_app():
|
|
229 |
|
230 |
|
231 |
ensure_gradio_frpc()
|
232 |
-
symlink_frpc_to_expected_location()
|
233 |
if __name__ == "__main__":
|
234 |
create_gradio_app().queue().launch(server_name="0.0.0.0", server_port=7860, share=True, debug=True, pwa=True)
|
|
|
23 |
KPipeline,
|
24 |
)
|
25 |
|
26 |
+
os.environ["HOME"] = "/tmp/home" # Prevent fallback to /root
|
27 |
+
os.makedirs("/tmp/home", exist_ok=True)
|
28 |
+
os.environ["GRADIO_TEMP_DIR"] = "/tmp/gradio"
|
29 |
os.environ["HF_HOME"] = "/tmp/huggingface"
|
30 |
os.environ["TRANSFORMERS_CACHE"] = "/tmp/huggingface/transformers"
|
31 |
os.environ["XDG_CACHE_HOME"] = "/tmp/huggingface"
|
32 |
os.environ["TORCH_HOME"] = "/tmp/torch"
|
33 |
os.environ["MOSHI_CACHE_DIR"] = "/tmp/moshi"
|
34 |
|
35 |
+
|
36 |
warnings.filterwarnings("ignore")
|
37 |
NUM_WORKERS = multiprocessing.cpu_count()
|
38 |
|
|
|
39 |
def ensure_gradio_frpc():
|
40 |
"""
|
41 |
+
Ensures the frpc binary is present in the location Gradio expects.
|
42 |
+
Avoids /.cache symlinks (which are not writable in HF Spaces).
|
43 |
"""
|
44 |
+
gradio_temp_dir = os.environ.get("GRADIO_TEMP_DIR", "/tmp/gradio")
|
45 |
+
target_dir = os.path.join(gradio_temp_dir, "frpc")
|
46 |
+
os.makedirs(target_dir, exist_ok=True)
|
47 |
|
48 |
+
frpc_file = os.path.join(target_dir, "frpc_linux_amd64_v0.3")
|
49 |
|
50 |
if not os.path.exists(frpc_file):
|
51 |
print(f"[INFO] Downloading frpc binary to: {frpc_file}")
|
|
|
57 |
except Exception as e:
|
58 |
print(f"[ERROR] Failed to download frpc binary: {e}")
|
59 |
else:
|
60 |
+
print("[INFO] frpc binary already exists at expected path.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
|
62 |
def process_segment(entry_and_voice_map):
|
63 |
entry, voice_map = entry_and_voice_map
|
|
|
219 |
|
220 |
|
221 |
ensure_gradio_frpc()
|
|
|
222 |
if __name__ == "__main__":
|
223 |
create_gradio_app().queue().launch(server_name="0.0.0.0", server_port=7860, share=True, debug=True, pwa=True)
|