Download source/scripts/deploy-hf.sh from WilburDev/earshelf: direct link, hf CLI and curl.
- Browser
- Download file 2.24 kB
-
https://huggingface.co/spaces/WilburDev/earshelf/resolve/main/source/scripts/deploy-hf.sh
- Command line
-
hf download hf://spaces/WilburDev/earshelf/source/scripts/deploy-hf.sh
-
curl -L -o deploy-hf.sh https://huggingface.co/spaces/WilburDev/earshelf/resolve/main/source/scripts/deploy-hf.sh
2.24 kB
| # Publish the built app as a static Hugging Face Space. | |
| # Usage: bash scripts/deploy-hf.sh [owner/space] (needs `hf auth login` once) | |
| # The voice model is NOT uploaded: on huggingface.co the app loads it from the Kokoro repo on the same CDN. | |
| set -euo pipefail | |
| cd "$(dirname "$0")/.." | |
| SPACE="${1:-WilburDev/earshelf}" | |
| STAGE="$(mktemp -d)" | |
| trap 'rm -rf "$STAGE"' EXIT | |
| npx vite build --outDir "$STAGE/site" --emptyOutDir | |
| rm -rf "$STAGE/site/models" "$STAGE/site/_headers" | |
| # precache.json never lists models/, so removing the folder keeps the offline cache valid | |
| # GPL-3.0: ship the licence, the notices and the complete corresponding source with every build | |
| cp LICENSE THIRD_PARTY_NOTICES.md "$STAGE/site/" | |
| mkdir -p "$STAGE/site/source" | |
| cp -r src tests scripts index.html package.json package-lock.json tsconfig.json vite.config.ts vitest.config.ts \ | |
| playwright.config.ts README.md LICENSE THIRD_PARTY_NOTICES.md "$STAGE/site/source/" | |
| mkdir -p "$STAGE/site/source/public" | |
| ( cd public && cp -r $(ls -A | grep -v '^models$') "$STAGE/site/source/public/" ) | |
| cat > "$STAGE/site/README.md" <<'EOF' | |
| --- | |
| title: EarShelf | |
| emoji: 🎧 | |
| colorFrom: yellow | |
| colorTo: red | |
| sdk: static | |
| app_file: index.html | |
| pinned: false | |
| license: gpl-3.0 | |
| short_description: Turn PDF and EPUB books into audiobooks on your device | |
| custom_headers: | |
| cross-origin-embedder-policy: credentialless | |
| cross-origin-opener-policy: same-origin | |
| cross-origin-resource-policy: cross-origin | |
| --- | |
| # EarShelf | |
| Drop a PDF, EPUB or TXT and listen to it. Everything runs in your browser: the book is never uploaded. | |
| The natural voice is [Kokoro-82M](https://huggingface.co/onnx-community/Kokoro-82M-v1.0-ONNX) (Apache-2.0), downloaded once and cached. | |
| Free software under the GPL-3.0 (see `LICENSE` and `THIRD_PARTY_NOTICES.md`). The complete source is in `source/`. | |
| Open the app full screen for best results: https://wilburdev-earshelf.static.hf.space | |
| EOF | |
| hf repo create "$SPACE" --repo-type space --space-sdk static --exist-ok | |
| hf upload "$SPACE" "$STAGE/site" . --repo-type space --delete "*" --commit-message "Deploy $(date -u +%Y-%m-%dT%H:%MZ)" | |
| echo "Live: https://huggingface.co/spaces/$SPACE (direct: https://${SPACE/\//-}.static.hf.space)" | tr 'A-Z' 'a-z' | |