File size: 2,239 Bytes
4a58e48
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4b4fd5e
4a58e48
 
 
 
4b4fd5e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env bash
# 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'