feat: add Dockerfile and Hugging Face Spaces config
Browse files- .dockerignore +9 -0
- Dockerfile +28 -0
- README.md +36 -6
.dockerignore
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.venv/
|
| 2 |
+
.env
|
| 3 |
+
__pycache__/
|
| 4 |
+
*.pyc
|
| 5 |
+
.git/
|
| 6 |
+
.DS_Store
|
| 7 |
+
data/
|
| 8 |
+
docs/
|
| 9 |
+
*.wav
|
Dockerfile
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.11-slim
|
| 2 |
+
|
| 3 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 4 |
+
espeak-ng \
|
| 5 |
+
curl \
|
| 6 |
+
ca-certificates \
|
| 7 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 8 |
+
|
| 9 |
+
RUN useradd -m -u 1000 hal
|
| 10 |
+
WORKDIR /app
|
| 11 |
+
|
| 12 |
+
COPY requirements.txt .
|
| 13 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 14 |
+
|
| 15 |
+
COPY download_model.py .
|
| 16 |
+
RUN python download_model.py
|
| 17 |
+
|
| 18 |
+
COPY hal_prompt.py main.py ./
|
| 19 |
+
COPY static/ ./static/
|
| 20 |
+
COPY profile.md ./
|
| 21 |
+
|
| 22 |
+
RUN mkdir -p /app/data && chown -R hal:hal /app
|
| 23 |
+
USER hal
|
| 24 |
+
|
| 25 |
+
ENV HAL_DATA_DIR=/app/data
|
| 26 |
+
EXPOSE 7860
|
| 27 |
+
|
| 28 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
README.md
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# HAL Voice MVP
|
| 2 |
|
| 3 |
-
Push-to-talk web app that lets you talk to HAL 9000. FastAPI backend wires Groq Whisper (STT) β Claude (LLM) β Piper TTS (HAL voice).
|
| 4 |
|
| 5 |
-
##
|
| 6 |
|
| 7 |
1. Install espeak-ng (macOS):
|
| 8 |
```
|
|
@@ -18,13 +29,14 @@ Push-to-talk web app that lets you talk to HAL 9000. FastAPI backend wires Groq
|
|
| 18 |
```
|
| 19 |
python download_model.py
|
| 20 |
```
|
| 21 |
-
4. Create `.env`
|
| 22 |
```
|
| 23 |
GROQ_API_KEY=gsk_...
|
| 24 |
ANTHROPIC_API_KEY=sk-ant-...
|
| 25 |
```
|
|
|
|
| 26 |
|
| 27 |
-
## Run
|
| 28 |
|
| 29 |
```
|
| 30 |
.venv/bin/uvicorn main:app --reload --port 8000
|
|
@@ -32,9 +44,27 @@ Push-to-talk web app that lets you talk to HAL 9000. FastAPI backend wires Groq
|
|
| 32 |
|
| 33 |
Open http://localhost:8000, hold the red eye to talk, release to send.
|
| 34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
## Notes
|
| 36 |
|
| 37 |
- English only. The Piper HAL model is English-only by design.
|
| 38 |
-
- Sessions live in
|
| 39 |
- Piper outputs 22050 Hz mono WAV, which browsers play natively.
|
| 40 |
-
- The HAL voice
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: HAL Voice MVP
|
| 3 |
+
emoji: π΄
|
| 4 |
+
colorFrom: red
|
| 5 |
+
colorTo: gray
|
| 6 |
+
sdk: docker
|
| 7 |
+
app_port: 7860
|
| 8 |
+
pinned: false
|
| 9 |
+
short_description: Push-to-talk conversation with HAL 9000's voice.
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
# HAL Voice MVP
|
| 13 |
|
| 14 |
+
Push-to-talk web app that lets you talk to HAL 9000. FastAPI backend wires Groq Whisper (STT) β Claude (LLM) β Piper TTS (HAL voice). Sessions persist to disk as JSON.
|
| 15 |
|
| 16 |
+
## Local setup
|
| 17 |
|
| 18 |
1. Install espeak-ng (macOS):
|
| 19 |
```
|
|
|
|
| 29 |
```
|
| 30 |
python download_model.py
|
| 31 |
```
|
| 32 |
+
4. Create `.env`:
|
| 33 |
```
|
| 34 |
GROQ_API_KEY=gsk_...
|
| 35 |
ANTHROPIC_API_KEY=sk-ant-...
|
| 36 |
```
|
| 37 |
+
5. (Optional) Edit `profile.md` with facts you want HAL to know about you.
|
| 38 |
|
| 39 |
+
## Run locally
|
| 40 |
|
| 41 |
```
|
| 42 |
.venv/bin/uvicorn main:app --reload --port 8000
|
|
|
|
| 44 |
|
| 45 |
Open http://localhost:8000, hold the red eye to talk, release to send.
|
| 46 |
|
| 47 |
+
## Deploy to Hugging Face Spaces
|
| 48 |
+
|
| 49 |
+
1. Create a new Space: https://huggingface.co/new-space
|
| 50 |
+
- SDK: **Docker**
|
| 51 |
+
- Hardware: **CPU Basic** (free)
|
| 52 |
+
- Visibility: Public (free) or Private ($9/mo)
|
| 53 |
+
2. Add repository secrets (Settings β Variables and secrets):
|
| 54 |
+
- `GROQ_API_KEY`
|
| 55 |
+
- `ANTHROPIC_API_KEY`
|
| 56 |
+
3. Push this repo to the Space:
|
| 57 |
+
```
|
| 58 |
+
git remote add space https://huggingface.co/spaces/<your-username>/<space-name>
|
| 59 |
+
git push space main
|
| 60 |
+
```
|
| 61 |
+
4. The Space builds from the `Dockerfile`. First build takes ~5 min (downloads the HAL model). Subsequent builds are cached.
|
| 62 |
+
5. Open the Space URL, hold the eye, talk.
|
| 63 |
+
|
| 64 |
## Notes
|
| 65 |
|
| 66 |
- English only. The Piper HAL model is English-only by design.
|
| 67 |
+
- Sessions live in `data/sessions/` as JSON. On HF Spaces free tier, the filesystem is ephemeral β sessions reset on restart/rebuild. For persistence across restarts, upgrade to a Space with persistent storage ($5/mo) and set `HAL_DATA_DIR=/data`.
|
| 68 |
- Piper outputs 22050 Hz mono WAV, which browsers play natively.
|
| 69 |
+
- The HAL voice loads once at startup.
|
| 70 |
+
- Edit `profile.md` to give HAL static context about you; it gets prepended to the system prompt on startup.
|