summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 4b2195906d655f1ad15aa1934e2c221ed6358da6 (plain)
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
54
55
56
57
58
# Maintainer: Seann <you@example.com>

pkgname=kokoro-tts
pkgver=2.3.1
pkgrel=1
pkgdesc='CLI text-to-speech tool using the Kokoro model'
arch=('x86_64')
url='https://github.com/nazdridoy/kokoro-tts'
license=('MIT')

options=('!debug' '!strip')

depends=(
  # Upstream declares requires-python >=3.11,<3.13.
  'python312'
  'ffmpeg'
  'portaudio'
)

source=()
sha256sums=()

package() {
  local appdir="$pkgdir/opt/$pkgname"
  local bindir="$pkgdir/usr/bin"

  install -d "$appdir" "$bindir"

  python3.12 -m venv "$appdir/venv"

  "$appdir/venv/bin/python" -m pip install \
    --upgrade \
    pip \
    wheel \
    setuptools

  "$appdir/venv/bin/python" -m pip install \
    "$pkgname==$pkgver"

  "$appdir/venv/bin/python" - <<'PY'
import importlib.metadata
import kokoro_tts

print("kokoro-tts:", importlib.metadata.version("kokoro-tts"))
print("kokoro_tts module:", kokoro_tts.__file__)
PY

  # Make venv scripts relocatable enough for /opt runtime.
  # Only edit files, because venv/bin may contain __pycache__ directories.
  find "$appdir/venv/bin" -maxdepth 1 -type f -exec sed -i "s|$pkgdir||g" {} +

  cat > "$bindir/kokoro-tts" <<'EOF'
#!/usr/bin/env bash
exec /opt/kokoro-tts/venv/bin/python -m kokoro_tts "$@"
EOF

  chmod 755 "$bindir/kokoro-tts"
}