Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -58,7 +58,26 @@ def log_env_for_audio():
|
|
| 58 |
print("[ENV] TTS_ENGINE =", os.getenv("TTS_ENGINE", "(unset)"))
|
| 59 |
print("[ENV] PIPER_MODEL=", os.getenv("PIPER_MODEL", "(unset)"))
|
| 60 |
print("[ENV] PIPER_BIN =", os.getenv("PIPER_BIN", "(unset)"))
|
|
|
|
|
|
|
| 61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
|
| 63 |
# -------------
|
| 64 |
# Application
|
|
@@ -74,7 +93,7 @@ def main():
|
|
| 74 |
# ensure_model()
|
| 75 |
|
| 76 |
# Make sure bundled Piper can run (no downloads on Spaces)
|
| 77 |
-
|
| 78 |
|
| 79 |
# Launch Gradio
|
| 80 |
demo = build_demo()
|
|
|
|
| 58 |
print("[ENV] TTS_ENGINE =", os.getenv("TTS_ENGINE", "(unset)"))
|
| 59 |
print("[ENV] PIPER_MODEL=", os.getenv("PIPER_MODEL", "(unset)"))
|
| 60 |
print("[ENV] PIPER_BIN =", os.getenv("PIPER_BIN", "(unset)"))
|
| 61 |
+
|
| 62 |
+
import os, stat
|
| 63 |
|
| 64 |
+
def ensure_piper_ready():
|
| 65 |
+
bin_path = os.getenv("PIPER_BIN", "piper")
|
| 66 |
+
model = os.getenv("PIPER_MODEL")
|
| 67 |
+
espeak = os.getenv("ESPEAK_DATA_PATH")
|
| 68 |
+
|
| 69 |
+
print(f"[PIPER] BIN={bin_path} exists={os.path.exists(bin_path)}")
|
| 70 |
+
print(f"[PIPER] MODEL={model} exists={os.path.exists(model) if model else None}")
|
| 71 |
+
print(f"[PIPER] ESPEAK_DATA_PATH={espeak} exists={os.path.exists(espeak) if espeak else None}")
|
| 72 |
+
|
| 73 |
+
# If PIPER_BIN is an absolute/relative file in repo, make it executable.
|
| 74 |
+
if bin_path and os.path.isfile(bin_path):
|
| 75 |
+
try:
|
| 76 |
+
st = os.stat(bin_path)
|
| 77 |
+
os.chmod(bin_path, st.st_mode | stat.S_IEXEC)
|
| 78 |
+
print("[PIPER] chmod +x applied to binary")
|
| 79 |
+
except Exception as e:
|
| 80 |
+
print("[PIPER] chmod failed:", e)
|
| 81 |
|
| 82 |
# -------------
|
| 83 |
# Application
|
|
|
|
| 93 |
# ensure_model()
|
| 94 |
|
| 95 |
# Make sure bundled Piper can run (no downloads on Spaces)
|
| 96 |
+
ensure_piper_ready()
|
| 97 |
|
| 98 |
# Launch Gradio
|
| 99 |
demo = build_demo()
|