Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: CI
on: [push, pull_request]
jobs:
skeleton:
host:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Placeholder
run: echo "TODO: add build / test / lint jobs per module"







- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install ffmpeg (compressed uploads)
run: sudo apt-get update && sudo apt-get install -y ffmpeg
- name: Install host
run: pip install -r host/requirements.txt pytest
- name: Test host (no models needed; backends are faked)
run: python -m pytest -q host
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ node_modules/
.venv/
__pycache__/
*.egg-info/
*.pyc
.pytest_cache/

# build outputs
dist/
Expand All @@ -12,10 +14,12 @@ build/
*.dylib
*.dll
*.exe
.build/

# local models / audio / secrets
*.gguf
*.onnx
!host/sessions/models/silero_vad_16k_op15.onnx
*.bin
*.wav
*.mp3
Expand Down
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,13 @@ See `docs/subsystems/` for one doc per subsystem.

## Status

Empty skeleton. Docs layout follows yetone/magpie.
Phase 1 host runs locally on Apple silicon: dictation (accurate / fast speech model), clean-up, translation, and a
Voxt-style respond mode with live streamed answers and follow-ups. See `docs/subsystems/asr-pipeline.md` for latency.

```bash
python3 -m venv .venv && .venv/bin/pip install -r host/requirements.txt
host/workers/start_local.sh # local models + host; then open http://127.0.0.1:8765/demo
```

API: `docs/reference.md` · clients: `docs/integrating.md` · demo: `docs/demo.md`.
Docs layout follows yetone/magpie.
9 changes: 8 additions & 1 deletion README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,11 @@ ASR + 实时翻译。情感化 TTS 与全双工打断插话在后续阶段加入

## 状态

空骨架。文档目录结构参考 yetone/magpie。
首期 Host 已可在 Apple silicon 本地运行:听写(精确 / 快速两档识别模型)、整理、翻译,以及类似 Voxt 的应答模式(流式输出、可追问)。时延见 `docs/subsystems/asr-pipeline.md`。

```bash
python3 -m venv .venv && .venv/bin/pip install -r host/requirements.txt
host/workers/start_local.sh # 启动本地模型和 Host,然后打开 http://127.0.0.1:8765/demo
```

接口:`docs/reference.md` · 客户端接入:`docs/integrating.md` · 演示:`docs/demo.md`。文档目录结构参考 yetone/magpie。
19 changes: 19 additions & 0 deletions apps/macos/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// swift-tools-version:5.9
// Pinned to 5.9 deliberately: this keeps the Swift 5 concurrency-checking
// language mode even when built with a newer (Swift 6) compiler, since
// Swift 6's stricter concurrency checks are an extra source of surprise
// errors this blind-written code hasn't been checked against. Can move to
// a newer tools-version later once the app builds clean and someone wants
// to actually adopt Swift 6 strict concurrency on purpose.
import PackageDescription

let package = Package(
name: "OpenVoice",
platforms: [.macOS(.v14)],
targets: [
.executableTarget(
name: "OpenVoice",
path: "Sources/OpenVoice"
)
]
)
122 changes: 122 additions & 0 deletions apps/macos/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# OpenVoice macOS Client

A native Swift/SwiftUI menu-bar app: tap a hotkey to start listening
hands-free, keep talking across as many sentences as you like, tap the
same hotkey again to stop. Everything is pasted at the cursor.

Three hotkeys, three modes (Settings → Hotkeys):

- **Transcribe** — pastes the raw transcript.
- **Translate** — translates into the language set in Settings, then pastes.
- **Agent** — answers what you said (spoken Q&A, with conversation
history across utterances in one session), then pastes the answer.
Called "respond" in `DictationMode`/the host API; shown as "Agent" in
the UI. Unlike the other two, Agent doesn't use the transient overlay
HUD — it opens a persistent window (`AgentChatWindowController.swift`)
that keeps every exchange on screen, appending new ones instead of
replacing, across as many Agent sessions as you start.

All three stream continuously to the local host's `/v1/listen` WebSocket
(`../../host`) — raw PCM16 audio out, live partial text and a final
result per sentence in. The host's own Silero VAD finds where each
sentence starts and ends; nothing runs on the client beyond capturing and
streaming the microphone (`PCMStreamer.swift`). Every model the host
talks to runs on this Mac; nothing leaves the device.

No Xcode required — builds with the Swift Package Manager (just Xcode
Command Line Tools: `xcode-select --install`).

## What's here

Key files under `Sources/OpenVoice/`:

- `OpenVoiceApp.swift` — app entry point, `MenuBarExtra` + windows scenes
- `DictationController.swift` — owns the hands-free session loop for all
three hotkeys
- `HotkeyManager.swift` — global tap-to-toggle hotkey detection
- `PCMStreamer.swift` — continuous 16kHz mono mic capture for `/v1/listen`
- `HostListenSession.swift` — the `/v1/listen` WebSocket client
- `HostClient.swift` — REST calls to the host: non-streaming `/v1/dictate`,
health, speaker enrolment
- `AudioRecorder.swift` — one-shot WAV recording, used only by the
speaker-enrolment flow in Settings
- `TextInjector.swift` — clipboard + simulated ⌘V paste
- `OverlayWindowController.swift` / `OverlayContentView.swift` — the
floating status/result HUD (Transcribe/Translate only)
- `AgentChatWindowController.swift` — the persistent, appending chat
window Agent mode uses instead
- `MainWindowView.swift` + `VocabularyView.swift` / `HistoryView.swift` /
`SettingsView.swift` — the tabbed window
- `AppSettings.swift` / `VocabularyStore.swift` / `HistoryStore.swift` —
persisted state

## Building and running it

```bash
cd apps/macos
./scripts/build-app.sh # debug build
open .build/OpenVoice.app
```

`swift build` alone only produces a bare executable — macOS won't show the
Microphone/Input Monitoring/Accessibility permission prompts correctly, or
respect `LSUIElement` (no Dock icon), for anything that isn't a real `.app`
bundle. `build-app.sh` does that wrapping: builds, assembles
`Contents/{MacOS,Resources}` + `Info.plist`, and code-signs it (required
even for local, unsigned runs — macOS won't launch certain entitled
operations on a completely unsigned binary).

No App Sandbox entitlement is ever added by this path — good, because
global hotkey monitoring and posting synthetic paste events don't work
inside the sandbox. This app has to ship unsandboxed either way.

**If permissions seem to reset every time you rebuild**: that's ad-hoc
signing's known instability — each rebuild can get treated as a "new app"
by TCC (the permissions system). Fix: create a local "Code Signing"
certificate in Keychain Access (Certificate Assistant → Create a
Certificate → type Code Signing), then build with:

```bash
OPENVOICE_SIGN_IDENTITY="Your Cert Name" ./scripts/build-app.sh
```

A stable signing identity keeps the same grant across rebuilds.

## Permissions

Three separate system permissions, all requested the first time the
relevant code path runs — macOS won't ask for them upfront:

| Permission | Why | Where to check/grant it |
| --- | --- | --- |
| Microphone | Mic capture (`PCMStreamer`, `AudioRecorder`) | System Settings → Privacy & Security → Microphone |
| Input Monitoring | `HotkeyManager`'s global `.flagsChanged` monitor | System Settings → Privacy & Security → Input Monitoring |
| Accessibility | `TextInjector`'s synthetic ⌘V | System Settings → Privacy & Security → Accessibility |

If a hotkey or paste doesn't seem to do anything, check these first —
macOS silently drops the relevant event stream instead of erroring when a
permission is missing, so "nothing happens" is the normal symptom.

## Testing it

1. Start the host and its model servers first (from `../../host`):
```bash
bash host/workers/start_local.sh
```
This needs vllm-metal set up — see `host/README.md` and
`docs/subsystems/model-workers.md` (if present) for details.
2. Run the app, tap the Transcribe hotkey, say a sentence, pause — it
should paste where the cursor was and keep listening. Tap the same
hotkey again to stop the session.
3. Check Settings → Host for the host URL (default
`http://127.0.0.1:8765`) and a health check.

## Known gaps / next steps

- Vocabulary (the "个人词库" tab) is sent as `options.dictionary` on every
listen session, but isn't surfaced anywhere in the UI beyond that — no
per-term aliases editor yet, just a flat word list.
- Agent mode has no MCP tool calling or confirm UI wired up on the
client side yet, even once the host has tools configured.
- Speaker labels (Settings → Speaker Labels) need the host started with
`OPENVOICE_SPEAKER_MODEL` set — see `host/sessions/models/README.md`.
Loading