File size: 2,367 Bytes
98e1028
009fd18
 
 
 
98e1028
4e34686
 
009fd18
 
 
 
98e1028
 
009fd18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
---
title: Browser Voice Agent Demo
emoji: 🎙️
colorFrom: indigo
colorTo: purple
sdk: static
app_build_command: npm run build && cp -r dist/* .
app_file: index.html
custom_headers:
  cross-origin-embedder-policy: require-corp
  cross-origin-opener-policy: same-origin
  cross-origin-resource-policy: cross-origin
---

# Browser Voice Agent Demo

Browser-first, on-device voice agent demo with Gradio-style camouflage. The app is served locally with Vite during development and built as static assets for public deployment.

## Stack

- `Vite` for local development, preview, and bundling
- `Bun` for package management and tests
- `@mlc-ai/web-llm` for local browser LLM inference
- `@huggingface/transformers` for local ASR
- Vendored Pocket TTS browser worker derived from `KevinAHM/pocket-tts-web`

## Local Development

```bash
bun install
bun run dev
```

Then open `http://localhost:3000`.

The same dev server now carries the isolation headers, so Pocket can take the threaded path without a separate custom preview server.

For a production-like static serve, use:

```bash
bun run preview
```

That serves the built `dist/` output with the same COOP/COEP/CORP headers.

## Test

```bash
bun test
```

## Build

```bash
bun run build
```

The production output is emitted to `dist/`.

## Pocket TTS Runtime

The app now ships a built-in Pocket TTS browser runtime and same-origin model assets:

- `src/vendor/pocket-tts/inference-worker.js`
- `src/vendor/pocket-tts/sentencepiece.js`
- `src/vendor/pocket-tts/CODE-LICENSE`
- `src/vendor/pocket-tts/onnx/*`
- `src/vendor/pocket-tts/tokenizer.model`
- `src/vendor/pocket-tts/voices.bin`
- `src/vendor/onnxruntime-web/*`

Those files are copied into `dist/` during `bun run build` and served locally from:

- `/pocket-tts/inference-worker.js`
- `/pocket-tts/sentencepiece.js`
- `/pocket-tts/onnx/*`
- `/pocket-tts/tokenizer.model`
- `/pocket-tts/voices.bin`
- `/onnxruntime-web/*`

The vendored worker code is Apache 2.0; its license file is preserved in [src/vendor/pocket-tts/CODE-LICENSE](/home/autark/src/private-voice-agent/src/vendor/pocket-tts/CODE-LICENSE).

For best Pocket performance, serve the app with:

- `Cross-Origin-Opener-Policy: same-origin`
- `Cross-Origin-Embedder-Policy: require-corp`

Without those headers, the worker still runs, but ONNX Runtime drops back to single-threaded WASM.