Spaces:
Sleeping
Sleeping
Throttle Gemini TTS podcast generation
Browse files- .gitattributes +2 -0
- start-hf.sh +39 -0
.gitattributes
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
|
|
|
|
|
| 1 |
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
*.bin filter=lfs diff=lfs merge=lfs -text
|
|
|
|
| 1 |
+
/.gitattributes text eol=lf
|
| 2 |
+
*.sh text eol=lf
|
| 3 |
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 4 |
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 5 |
*.bin filter=lfs diff=lfs merge=lfs -text
|
start-hf.sh
CHANGED
|
@@ -20,6 +20,9 @@ if [ -n "${VERTEX_SERVICE_ACCOUNT_JSON_B64:-}" ]; then
|
|
| 20 |
export GOOGLE_APPLICATION_CREDENTIALS=/data/open-notebook/secrets/vertex-sa.json
|
| 21 |
fi
|
| 22 |
|
|
|
|
|
|
|
|
|
|
| 23 |
/app/.venv/bin/python - <<'PY'
|
| 24 |
from pathlib import Path
|
| 25 |
import re
|
|
@@ -277,6 +280,42 @@ if "_is_gemini_tts_model" not in src:
|
|
| 277 |
print(f"Patched Vertex TTS provider: {target}")
|
| 278 |
PY
|
| 279 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 280 |
(
|
| 281 |
/app/.venv/bin/python - <<'PY'
|
| 282 |
import asyncio
|
|
|
|
| 20 |
export GOOGLE_APPLICATION_CREDENTIALS=/data/open-notebook/secrets/vertex-sa.json
|
| 21 |
fi
|
| 22 |
|
| 23 |
+
export TTS_BATCH_SIZE="${TTS_BATCH_SIZE:-1}"
|
| 24 |
+
export TTS_BATCH_DELAY_SECONDS="${TTS_BATCH_DELAY_SECONDS:-65}"
|
| 25 |
+
|
| 26 |
/app/.venv/bin/python - <<'PY'
|
| 27 |
from pathlib import Path
|
| 28 |
import re
|
|
|
|
| 280 |
print(f"Patched Vertex TTS provider: {target}")
|
| 281 |
PY
|
| 282 |
|
| 283 |
+
/app/.venv/bin/python - <<'PY'
|
| 284 |
+
from pathlib import Path
|
| 285 |
+
import re
|
| 286 |
+
|
| 287 |
+
import podcast_creator
|
| 288 |
+
|
| 289 |
+
target = Path(podcast_creator.__file__).resolve().parent / "nodes.py"
|
| 290 |
+
src = target.read_text(encoding="utf-8")
|
| 291 |
+
|
| 292 |
+
src, batch_count = re.subn(
|
| 293 |
+
r'batch_size = int\(os\.getenv\("TTS_BATCH_SIZE", "5"\)\)',
|
| 294 |
+
'batch_size = int(os.getenv("TTS_BATCH_SIZE", "1"))',
|
| 295 |
+
src,
|
| 296 |
+
count=1,
|
| 297 |
+
)
|
| 298 |
+
|
| 299 |
+
if "TTS_BATCH_DELAY_SECONDS" not in src:
|
| 300 |
+
src, delay_count = re.subn(
|
| 301 |
+
r" # Small delay between batches to be extra safe with API limits\n"
|
| 302 |
+
r" if batch_end < total_segments:\n"
|
| 303 |
+
r" await asyncio\.sleep\(1\)",
|
| 304 |
+
" # Delay between batches to respect Gemini-TTS per-minute quotas.\n"
|
| 305 |
+
" if batch_end < total_segments:\n"
|
| 306 |
+
' await asyncio.sleep(float(os.getenv("TTS_BATCH_DELAY_SECONDS", "65")))',
|
| 307 |
+
src,
|
| 308 |
+
count=1,
|
| 309 |
+
)
|
| 310 |
+
if delay_count != 1:
|
| 311 |
+
raise RuntimeError("Could not patch podcast_creator TTS batch delay; source layout changed")
|
| 312 |
+
|
| 313 |
+
if batch_count > 0 or "TTS_BATCH_DELAY_SECONDS" in src:
|
| 314 |
+
target.write_text(src, encoding="utf-8")
|
| 315 |
+
|
| 316 |
+
print(f"Patched podcast_creator TTS rate limiting: {target}")
|
| 317 |
+
PY
|
| 318 |
+
|
| 319 |
(
|
| 320 |
/app/.venv/bin/python - <<'PY'
|
| 321 |
import asyncio
|