Skip to content

Commit 1cebcfb

Browse files
committed
Public release: detailed README (KO), MIT license
1 parent 72bfdd0 commit 1cebcfb

2 files changed

Lines changed: 163 additions & 89 deletions

File tree

‎LICENSE‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 Codebasic
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

‎README.md‎

Lines changed: 142 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,91 @@
1-
# SelectedTextTTS
1+
# Codebasic TTS
22

3-
macOS menu-bar utility: select text anywhere → right-click → **Services → "Read with
4-
SelectedTextTTS"** → high-quality TTS reads it aloud, with per-sentence caching.
3+
macOS용 TTS 앱: **텍스트를 선택하고 단축키 한 번으로 AI 음성 읽기 + LLM 코드 해설**까지.
54

6-
This repo is built **without Xcode** (only Command Line Tools are installed). A small
7-
`build.sh` compiles with `swiftc` and assembles the `.app` bundle by hand. It is still a
8-
plain AppKit project and can be imported into Xcode later if desired.
5+
- 아무 앱에서 텍스트 선택 → **⌃⌥⌘R** (또는 우클릭 → Services → "Codebasic TTS") → 곧바로 음성 재생
6+
- 코드 선택 → **⌃⌥⌘E** → 연결된 LLM이 코드를 해설하고, 그 해설을 음성으로 읽어줌
7+
- ElevenLabs(클라우드)와 로컬 Qwen3-TTS(MLX, 음성 클론) 중 선택해서 사용
8+
- 문장 단위 스트리밍 재생, 문장별 음성 캐싱으로 반복 재생 즉시 반응
9+
- TTS 스크립트를 다듬어주는 LLM 스크립트 편집기 + 용어집(glossary) 내장
910

10-
## Status: M1 (skeleton)
11+
| | |
12+
|---|---|
13+
| 플랫폼 | macOS 13.0+ (Apple Silicon 최적화, Intel 미검증) |
14+
| 요구사항 | 없음 — Xcode/Python 사전 설치 불필요 (릴리스 앱 기준) |
15+
| 라이선스 | MIT |
16+
| 다운로드 | [Releases](../../releases/latest) 에서 `Codebasic-TTS.app.zip` |
1117

12-
M1 = menu-bar agent + macOS Services registration + selected-text logging. **No audio yet.**
13-
The `TTSBackend` protocol (the pluggable engine abstraction) is defined; only a no-op
14-
`StubBackend` is wired in. Audio playback arrives in M2.
18+
---
1519

16-
## Build & run
20+
## 빠른 시작 (일반 사용자)
21+
22+
1. [Releases](../../releases/latest)에서 **`Codebasic-TTS.app.zip`** 을 내려받아 압축 해제
23+
2. `Codebasic TTS.app`을 **응용 프로그램 폴더 또는 ~/Applications로 이동**
24+
3. 첫 실행: **우클릭 → "열기"** (개발자 서명이 없어 Gatekeeper 경고가 뜹니다 —
25+
브릿지 경고 없이 열리면 재부팅 후에도 다시 묻지 않습니다. 자세한 설명은 아래
26+
[보안 경고](#보안-경고-gatekeeper) 참고)
27+
4. 메뉴 막대의 🔊 아이콘 → **설정**에서 사용할 엔진과 API 키 입력:
28+
- **ElevenLabs**: [elevenlabs.io](https://elevenlabs.io) 에서 발급한 API 키
29+
(무료 티어로도 충분히 써볼 수 있습니다)
30+
- **로컬 Qwen3-TTS**(선택): "로컬 엔진 설정" 버튼 — 첫 실행 시 Apple Silicon에
31+
Qwen3-TTS(1.7B, 6bit 양자화) 모델을 내려받고 Python 가상환경을 자동 구성합니다.
32+
인터넷 연결과 수 GB 디스크 여유가 필요하며, 이후에는 완전 오프라인 동작
33+
5. (전역 단축키를 쓸 경우) **시스템 설정 → 개인정보 보호 및 보안 → 손쉬운 사용**에서
34+
`Codebasic TTS` 허용 — 앱이 이 화면을 자동으로 열어줍니다
35+
6. 텍스트 선택 → **⌃⌥⌘R** → 재생 🎧
36+
37+
> 서비스 메뉴(우클릭 → Services)는 앱이 한 번 실행된 이후에 나타납니다.
38+
39+
## 사용법
40+
41+
| 동작 | 방법 |
42+
|---|---|
43+
| 선택 텍스트 읽기 | ⌃⌥⌘R 또는 우클릭 → Services → "Codebasic TTS" |
44+
| 선택 코드 해설 후 읽기 | ⌃⌥⌘E 또는 Services → "Codebasic TTS: 코드 해설" |
45+
| 일시정지 / 정지 | 재생 HUD 또는 메뉴 막대 아이콘 메뉴 |
46+
| 스크립트 편집 · 해설 보기 | 메뉴 막대 아이콘 클릭 → 관리 창 |
47+
48+
**음성 엔진**
49+
50+
| 엔진 | 특징 | 준비물 |
51+
|---|---|---|
52+
| ElevenLabs | 고품질 클라우드 합성, 스트리밍 | API 키 |
53+
| 로컬 Qwen3-TTS (MLX) | 오프라인, 내 목소리 클론 재생, 무료 | Apple Silicon, 최초 1회 모델 다운로드 |
54+
55+
로컬 엔진은 레퍼런스 음성(수 초 길이 녹음)으로 **voice cloning**을 지원합니다.
56+
설정에서 레퍼런스 오디오/전사 텍스트를 지정하세요.
57+
58+
**텍스트 생성(LLM)** — 코드 해설(⌃⌥⌘E)과 스크립트 다듬기에는 OpenAI 호환 API,
59+
Gemini, Ollama 등 **사용자가 직접 등록한 엔드포인트**를 사용합니다. 기본 제공
60+
엔드포인트는 없으며, 설정 → 텍스트 생성에서 베이스 URL·모델·API 키를 추가하면 됩니다.
61+
API 키는 macOS 키체인이 아닌 앱 전용 Application Support 디렉토리에 저장되고
62+
네트워크로 전송되지 않습니다(요청 대상 엔드포인트 제외).
63+
64+
## 빌드 (소스에서)
65+
66+
Xcode 없이 **Command Line Tools만**으로 빌드됩니다.
1767

1868
```bash
19-
./build.sh # build → install to ~/Applications → register Services → launch
20-
./build.sh dev # build → run in THIS terminal (stdout/os_log visible, no install)
21-
./build.sh build # build into ./build only
22-
./build.sh test # compile + run the unit tests (TextSplitter, subtitle alignment)
23-
./build.sh logs # tail the app's unified logs
24-
./build.sh clean # remove ./build
69+
xcode-select --install # 최초 1회
70+
git clone https://github.com/codebasic/Codebasic-TTS.git
71+
cd Codebasic-TTS
72+
./build.sh # 빌드 → ~/Applications 설치 → Services 등록 → 실행
73+
./build.sh build # ./build 에만 빌드 (설치·등록 안 함)
74+
./build.sh dev # 빌드 후 이 터미널에서 포그라운드 실행 (로그 직접 출력)
75+
./build.sh test # 단위 테스트 (TextSplitter, 자막 정렬)
76+
./build.sh logs # 앱 통합 로그 스트리밍
77+
./build.sh clean # ./build 삭제
2578
```
2679

27-
> Launch Services only reliably scans `~/Applications` and `/Applications`, so `./build.sh`
28-
> installs there. Running the `.app` from `./build` may **not** make the Service appear.
29-
30-
## Stable signing (keep the global-hotkey Accessibility grant across rebuilds)
80+
> Launch Services는 `~/Applications`와 `/Applications`만 확실히 스캔합니다.
81+
> `./build/` 안에서 앱을 직접 실행하면 Services 메뉴에 안 나타날 수 있습니다.
3182
32-
The global hotkeys (⌃⌥⌘R read, ⌃⌥⌘E explain) need **Accessibility** permission. With
33-
ad-hoc signing the grant is bound to the binary's cdhash, so every rebuild silently
34-
invalidates it — the toggle still shows *on* in System Settings, but pressing the hotkey
35-
just re-opens the permission prompt. Sign with a **stable self-signed identity** to fix this
36-
once and for all.
83+
### 안정적 서명 (Stable signing)
3784

38-
One-time cert creation (scripted — creates `Codebasic TTS Local` in the login keychain):
85+
전역 단축키(⌃⌥⌘R/E)에 필요한 **손쉬운 사용** 권한은 서명 해시에 묶입니다. ad-hoc
86+
서명은 재빌드할 때마다 권한이 조용히 풀립니다. 다음 명령으로 **자체 서명 인증서를 한
87+
번만 만들어두면** (`Codebasic TTS Local`) 재빌드 후에도 권한이 유지됩니다.
88+
`build.sh`는 이 인증서가 있으면 자동으로 사용하고, 없으면 ad-hoc으로 빌드합니다:
3989

4090
```bash
4191
TMP="$(mktemp -d)"
@@ -53,91 +103,94 @@ extendedKeyUsage = critical,codeSigning
53103
EOF
54104
openssl req -x509 -newkey rsa:2048 -sha256 -days 3650 -nodes \
55105
-keyout "$TMP/key.pem" -out "$TMP/cert.pem" -config "$TMP/ext.cnf"
56-
# NOTE: a non-empty -passout is required, else Apple's `security import` fails MAC verification
106+
# -passout 이 비어 있으면 Apple security import 가 MAC verification 오류로 실패합니다
57107
openssl pkcs12 -export -inkey "$TMP/key.pem" -in "$TMP/cert.pem" \
58108
-out "$TMP/id.p12" -passout pass:codebasic -name "Codebasic TTS Local"
59109
security import "$TMP/id.p12" -k ~/Library/Keychains/login.keychain-db \
60110
-P codebasic -A -T /usr/bin/codesign
61111
rm -rf "$TMP"
62112
```
63113

64-
(Alternatively, Keychain Access → Certificate Assistant → **Create a Certificate…**,
65-
Name `Codebasic TTS Local`, Self-Signed Root, Code Signing.)
114+
(또는 키체인 접근 → 인증 지원 → **인증서 만들기…** → 이름 `Codebasic TTS Local`,
115+
자체 서명 루트, 코드 서명.)
66116

67-
The cert is *untrusted* (`CSSMERR_TP_NOT_TRUSTED`) — that's fine: `codesign` still signs with
68-
it and the designated requirement becomes a stable `certificate leaf = H"…"`, which is all TCC
69-
needs. `build.sh` detects it with `security find-identity -p codesigning` (no `-v`, since `-v`
70-
hides untrusted identities). Then grant once:
117+
이 인증서는 *신뢰되지 않는* 인증서입니다(CSSMERR_TP_NOT_TRUSTED) — 그래도 괜찮습니다:
118+
codesign은 서명에 사용하며, designated requirement가 안정적이기만 하면 TCC 권한이
119+
유지됩니다. 이후:
71120

72121
```bash
73-
./build.sh # signs with the cert (see its log line)
74-
tccutil reset Accessibility com.seongjoo.SelectedTextTTS # clear the old ad-hoc grant once
75-
# press ⌃⌥⌘R → grant in System Settings → Privacy & Security → Accessibility
122+
./build.sh # 인증서로 서명됨
123+
tccutil reset Accessibility com.seongjoo.SelectedTextTTS # 예전 ad-hoc 권한 1회 정리
124+
# ⌃⌥⌘R 눌러서 손쉬운 사용 권한 부여 — 이후 재빌드에도 유지
76125
```
77126

78-
After this, rebuilds keep the permission. Override the identity name with
79-
`CODESIGN_IDENTITY="…" ./build.sh` if you named it differently.
80-
81-
## Smoke test (M1)
127+
## 보안 경고 (Gatekeeper)
82128

83-
1. `./build.sh` — installs, registers, and launches the app (🔊 appears in the menu bar).
84-
2. In **TextEdit**, type and select a line of text.
85-
3. Right-click → **Services → "Read with SelectedTextTTS"** (or the app menu → Services).
86-
4. Confirm it fired:
87-
- menu-bar 🔊 briefly flips to 🔈,
88-
- its menu's "Last selection: …" updates,
89-
- `./build.sh logs` shows `Service fired: received N chars`.
129+
이 앱은 Apple Developer ID 서명이 없어(비용 문제) 최초 실행 시
130+
**"확인되지 않은 개발자"** 경고가 뜹니다. 개발자 서명·공증이 없는 것 외에 다른
131+
제한은 없으며, 서명 자체는 유효합니다(`codesign --verify --deep` 통과).
90132

91-
For fast iteration during development, prefer `./build.sh dev`: it runs the binary in the
92-
foreground so logs print straight to your terminal. (The Services menu item still resolves
93-
to the copy registered in `~/Applications`, so keep one `./build.sh` install around.)
133+
- **우클릭 → 열기**로 실행하면 한 번 확인 후 정상 실행됩니다.
134+
이후 같은 위치에서는 다시 묻지 않습니다.
135+
- 새 버전을 덮어쓴 뒤 다시 경고가 뜨면 같은 방법으로 열면 됩니다.
136+
- 이 앱이 손쉬운 사용(전역 단축키), 마이크·키체인 접근 등의 권한을 요청하는 것은
137+
정상 동작이며, 요청 화면이 뜨면 시스템 설정에서 확인하고 허용하세요.
94138

95-
## Service not appearing in the menu?
139+
## 서비스 메뉴가 안 보일 때
96140

97-
Order of things to try:
98-
99-
1. `./build.sh` again (re-runs `lsregister -f` + `pbs -update/-flush`).
100-
2. Make sure you tested from an app that exposes Services well (TextEdit is reliable).
101-
3. Manually re-register:
141+
1. `./build.sh` 다시 실행 (`lsregister -f` + `pbs -update/-flush` 재수행)
142+
2. Services 노출이 잘 되는 앱에서 테스트 (TextEdit이 확실)
143+
3. 수동 재등록:
102144
```bash
103145
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister \
104-
-f ~/Applications/SelectedTextTTS.app
146+
-f ~/Applications/"Codebasic TTS.app"
105147
/System/Library/CoreServices/pbs -update
106148
```
107-
4. **Last resort:** log out and back in. `pbs` sometimes only rescans on session start;
108-
a missing menu item after the steps above is a registration quirk, *not* a code bug.
149+
4. 최후: 로그아웃 후 다시 로그인. 위 단계 후에도 메뉴가 안 보이면 등록 이슈이지
150+
코드 문제가 아닙니다.
151+
152+
## 로컬 TTS 사이드카 (고급)
109153

110-
## Layout
154+
로컬 Qwen3-TTS 엔진은 별도 Python 프로세스(사이드카)가 `127.0.0.1` HTTP로 합성을
155+
담당하고, Swift 앱이 여기에 붙는 구조입니다. 수동 구성이 필요한 경우:
111156

157+
```bash
158+
cd Sidecar
159+
uv venv --python 3.12 .venv
160+
VIRTUAL_ENV=$PWD/.venv uv pip install -r requirements.txt
161+
QWEN_TTS_REF_AUDIO=/path/to/ref.wav \
162+
QWEN_TTS_REF_TEXT=/path/to/ref.txt \
163+
.venv/bin/python server.py # 기본 127.0.0.1:8765
112164
```
113-
SelectedTextTTS/
114-
├── build.sh # swiftc build + bundle assembly + LS registration
115-
├── Resources/Info.plist # LSUIElement + NSServices definition
116-
└── Sources/
117-
├── App/main.swift # programmatic NSApplication entry point
118-
├── App/AppDelegate.swift # menu-bar item, Services registration, selection handler
119-
├── Service/ServiceProvider.swift # NSServices handler (readSelectedText:userData:error:)
120-
├── Core/Logging.swift # os_log wrappers (why: LSUIElement print() is invisible)
121-
└── TTS/TTSBackend.swift # TTSBackend protocol + VoiceConfig + StubBackend
165+
166+
- `GET /health` → `{status, model, sample_rate, ready}`
167+
- `POST /tts` → `audio/wav` (body: `{"text": "...", "temperature"?, "speed"?}`)
168+
169+
음성 클론 테스트 CLI:
170+
171+
```bash
172+
Sidecar/tts # REPL: 모델 1회 로드, 여러 문장 반복 테스트
173+
Sidecar/tts "읽을 문장" # 원샷: 합성 + 재생
174+
Sidecar/tts "문장" -o out.wav # 원샷: out.wav 에 저장
175+
Sidecar/tts -m 4bit # 양자화 선택 (4bit|5bit|6bit|8bit|bf16)
122176
```
123177

124-
## Roadmap
125-
126-
| Milestone | Scope |
127-
|-----------|-------|
128-
| **M1 ✅** | Menu-bar agent, Services registration, selected-text logging |
129-
| M2 | ElevenLabs `/stream` → `AVQueuePlayer`, one-shot playback (no cache) |
130-
| M3 | `NLTokenizer` sentence segmentation + per-segment disk cache |
131-
| M4 | Partial / suffix-extended selection reuse |
132-
| M5 | Local `Qwen3MLXBackend` (Python `mlx-audio` sidecar), backend toggle |
133-
| M6 | Keychain API key, error/offline handling, voice-selection UI |
134-
135-
### Note on the local model
136-
137-
The handoff's final line asks to "run the local model first in M1." That is deferred on
138-
purpose: `mlx` / `mlx_audio` are not importable in this machine's Python (3.14.5 — too new
139-
for current MLX wheels), so the local engine needs its own venv (Python 3.11/3.12) set up as
140-
a parallel track before M5. M1 ships the skeleton + the backend abstraction so either engine
141-
can drop in behind `TTSBackend`. Voice-clone assets already exist in the repo root
142-
(`ref_sj.wav`, `voice_clone_prompt_sj.pt`, `ref_text.txt`).
178+
## 구조
179+
180+
```
181+
Codebasic-TTS/
182+
├── build.sh # swiftc 빌드 + 번들 조립 + Launch Services 등록
183+
├── Resources/Info.plist # LSUIElement + NSServices 정의
184+
├── Sources/
185+
│ ├── App/ # 진입점, 메뉴 막대, 전역 단축키, 엔드포인트/시크릿
186+
│ ├── Service/ServiceProvider.swift # NSServices 핸들러 (read/explain)
187+
│ ├── Core/ # 문장 분할, 캐시, 큐 재생, 원문 정규화
188+
│ ├── TTS/ # TTSBackend 프로토콜 + ElevenLabs/로컬 Qwen3 백엔드
189+
│ ├── UI/ # 관리 창, 설정, 스크립트 편집기, 플레이어 오버레이
190+
│ └── Tests/main.swift # 단위 테스트
191+
└── Sidecar/ # 로컬 Qwen3-TTS(MLX) FastAPI 사이드카
143192
```
193+
194+
## 라이선스
195+
196+
[MIT](LICENSE) © Codebasic

0 commit comments

Comments
 (0)