Skip to content

Phase 1 host: local dictation, translation and respond mode - #2

Closed
aliparchekan wants to merge 1 commit into
ThinkFlowLab:mainfrom
aliparchekan:backend-phase1
Closed

aliparchekan wants to merge 1 commit into
ThinkFlowLab:mainfrom
aliparchekan:backend-phase1

Conversation

@aliparchekan

Copy link
Copy Markdown

What this adds

A working phase-1 Personal Host that runs fully on a Mac (Apple silicon), placed in the existing skeleton:

Path What it is
host/sessions/ Voice-session API: POST /v1/dictate (multipart audio), POST /v1/translate, POST /v1/respond, and a WebSocket stream
host/router/ Per-stage model routes from env vars: accurate/fast ASR, LLM, translation
host/workers/ start_local.sh (vllm-metal model servers + host), a 4-bit ASR quantizer, an MLX cache cap
client/demo/ Test page at /demo: hold-to-talk, hands-free, streaming conversation
docs/ reference.md (API, contract 0.4), integrating.md, demo.md, openapi.yaml, and the phase-1 subsystem docs

Modes

  • Dictation: Qwen3-ASR-1.7B, then a clean-up gate. The LLM (Qwen3-4B 4-bit) runs only when the transcript has fillers or repeats; Qwen3-ASR already punctuates.
  • Translation: of the raw transcript (spoken), or of text (/v1/translate). 35 languages; the model is routable.
  • Respond: Voxt-style ask or rewrite, optionally on selected text and in another language.
    • Answers stream as they are written (?stream=1, server-sent events).
    • Follow-ups carry history.

Scope note: respond mode goes beyond AGENTS.md's "ASR + translation" phase-1 scope. We included it deliberately. Its lookups (weather via wttr.in, Wikipedia search) are off unless OPENVOICE_TOOLS=1, so by default nothing leaves the device. TTS and full-duplex are not in this PR.

Measured (M1 Max, 32 GB, warm, through the host)

Median p90
Dictation, accurate ~320 ms ~660 ms
Dictation, fast (4-bit ASR) ~215 ms ~510 ms
Translation of speech ~0.5 s
Respond, first words ~0.55 s
Follow-up, first words ~0.1 s
  • Accuracy on 320 real ASCEND clips, mixed Chinese-English MER: 7.98% (accurate), 8.86% (fast), 24.3% (Whisper large-v3).
  • Memory: about 11 GB for phase 1.

Try it

python3 -m venv .venv && .venv/bin/pip install -r host/requirements.txt
host/workers/start_local.sh     # needs vllm-metal, see docs/subsystems/model-workers.md
open http://127.0.0.1:8765/demo

Checks

  • python -m pytest -q host: 38 passing. Backends are faked, so CI needs no models; .github/workflows/ci.yml now runs them.
  • Live on the Mac: all four modes, fast/accurate, a streamed respond, and the demo page.

Not in this PR / open

  • TTS, full-duplex, and the macOS menu-bar app (hotkey dictation). Those are later phases or a separate PR.
  • Web search needs OPENVOICE_CONTACT (a project URL or email) for Wikimedia's robot policy. Which contact to publish is a team decision.
  • No licence file yet. The clean-up prompt is adapted from Voxt (Apache-2.0); attribution is in host/sessions/prompts/NOTICE.

🤖 Generated with Claude Code

host/sessions: voice-session API (/v1/dictate, /v1/translate, /v1/respond, WebSocket stream)
  - dictation with a clean-up gate (LLM only when there are fillers or repeats)
  - spoken and typed translation
  - respond mode (Voxt-style ask/rewrite) with streamed answers and follow-ups;
    weather and Wikipedia tools are opt-in (OPENVOICE_TOOLS=1)
host/router: per-stage model routes from the environment (accurate/fast ASR, LLM, translation)
host/workers: start_local.sh (vllm-metal servers + host), 4-bit ASR quantizer, MLX cache cap
client/demo: test page (hold-to-talk, hands-free, streaming conversation)
docs: reference, integrating, demo run sheet, OpenAPI, and the phase-1 subsystem docs
ci: run the host tests (backends faked; no models needed)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@agent-ci-infra-bot agent-ci-infra-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed commit: 48c7096
Coverage: PR #2; 33 changed file(s)

Comment thread host/sessions/app.py
@app.get("/v1/capabilities")
async def capabilities(request: Request):
auth(request)
return dict(contract="0.3", modes=["transcribe", "polish", "translate"],

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

F1 — high, must-fix, API contract — /v1/capabilities omits respond and still reports contract: "0.3"

  • Where: host/sessions/app.py:193
  • Problem: capabilities() returns contract="0.3", modes=["transcribe", "polish", "translate"], although this PR adds respond mode and its own docs call respond "contract 0.4" (docs/reference.md:127). The same response already carries respond-only metadata (tools, output_languages), so this is an omission rather than a deliberate choice to hide the mode. docs/reference.md says "Apps read this at start and hide what is not available", so a capability-driven client will never offer respond.
  • Conditions: any client that builds its mode list from GET /v1/capabilities, which is the documented integration path. The bundled demo masks the bug because client/demo/index.html hardcodes <option value="respond">.
  • Impact: third-party clients cannot discover or gate the PR's headline mode, and clients that gate on the advertised contract version (0.3 vs the documented 0.4) also treat respond as unsupported.
  • Fix: return contract="0.4" and modes=["transcribe", "polish", "translate", "respond"]. Add a regression assertion to host/sessions/test_sessions.py (for example in test_http_and_retry or test_translate_text_endpoint): assert "respond" in c.get("/v1/capabilities").json()["modes"], and align the capabilities example in docs/reference.md.

Verified against a mock backend: the response is {"contract": "0.3", "modes": ["transcribe", "polish", "translate"], ...} with tools present.

Comment thread host/sessions/app.py
for _ in range(3): # at most two tool rounds, then a final answer
text, pending = "", {}
async with app.state.client.stream("POST", urls["llm"] + "/v1/chat/completions", json={
"model": models["llm"], "messages": messages, "temperature": 0, "max_tokens": 400,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

F2 — medium, must-fix, truncation — Streamed respond answers are silently cut off at 400 tokens

  • Where: host/sessions/app.py:224
  • Problem: every respond round is requested with "max_tokens": 400, and the stream loop reads only delta.content and delta.tool_calls; finish_reason is never inspected. The polish path rejects finish_reason != "stop" (app.py:313) and translate() does too (app.py:208), so respond is the one stage that returns a truncated model answer as if it were final.
  • Conditions: any answer or rewrite longer than roughly 300 words — for example "rewrite this" on a long context.selected_text (the option accepts 8,000 characters) or "summarize/explain …" requests.
  • Impact: the app inserts a rewrite that stops mid-sentence, no warning is produced, and the partial answer is appended to the client's history, so follow-ups reason about a truncated turn. Confirmed with a mock stream whose last chunk is finish_reason: "length": the endpoint returned the partial text with warnings: [] and no error.
  • Fix: raise the cap for the final (non-tool) round and treat finish_reason == "length" as incomplete — continue the completion, or return a warning such as respond_truncated (and document it in reference.md). Add a stream test whose final chunk carries finish_reason: "length" and assert the visible behaviour.

Comment thread host/sessions/app.py
try:
r = await app.state.client.post(urls["mt"] + "/v1/chat/completions", json={
"model": models["mt"], "messages": prompts.translation(text, target, dictionary),
"temperature": 0, "max_tokens": 1024})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

F3 — medium, must-fix, API contract — /v1/translate accepts 8,000 characters but caps the model at 1,024 tokens

  • Where: host/sessions/app.py:204
  • Problem: translate() always requests max_tokens: 1024, while POST /v1/translate documents text up to 8,000 characters (docs/reference.md:145) and speech translate can pass the transcript of a 600-second recording. Because the function correctly rejects finish_reason != "stop" (app.py:208), any translation longer than 1,024 tokens is treated as a model failure instead of being completed: /v1/translate answers 502 mt_failed, and speech translate falls back to the untranslated transcript with translate_failed.
  • Conditions: a translation whose output exceeds 1,024 tokens — roughly 800+ English words or 1,500+ Chinese characters (a token estimate; I did not run a real model).
  • Impact: the documented input range fails for an ordinary use of /v1/translate ("typed, pasted or selected text"): pasting a paragraph or an email returns 502 and the user gets no translation.
  • Fix: size the cap from the source (for example min(8192, 2 * len(text) + 256)), or split long text into chunks and join the translations; otherwise lower the documented 8,000-character limit to what the output cap can actually return. Add coverage for both: the request's max_tokens grows with a long input, and a length finish still maps to mt_failed.

Comment thread host/sessions/app.py
raise ValueError
if "<asr_text>" in raw and raw.startswith("language "):
prefix, raw = raw.split("<asr_text>", 1)
language = {"English": "en", "Chinese": "zh"}.get(prefix[9:].strip(), language)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

F4 — medium, suggestion, ASR — language is only decoded for English and Chinese

  • Where: host/sessions/app.py:288
  • Problem: Qwen3-ASR prefixes the transcript with the detected language (language X<asr_text>…), but the map only knows English and Chinese. For any other language the result keeps language: "auto", and process() then appends language_uncertain (app.py:300) even though the recognizer named the language.
  • Conditions: dictating Japanese, Korean, French, … with language: "auto".
  • Impact: clients that use language for UI, history or the next stage get "auto", and a false language_uncertain warning is reported for speech the recognizer actually identified. Verified with a mock ASR answer language Japanese<asr_text>こんにちは: the result was {"language": "auto", "warnings": ["language_uncertain"]}.
  • Fix: map the languages Qwen3-ASR reports (or normalise the prefix to a BCP-47 code) and append language_uncertain only when no language was detected. Add the Japanese case to test_sessions.py.

Comment thread docs/reference.md

```json
{
"contract": "0.1",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

F6 — medium, suggestion, docs — The API docs disagree with the implemented capabilities and result shape

  • Where: docs/reference.md:107
  • Problem: the GET /v1/capabilities example still shows "contract": "0.1", "modes": ["transcribe", "polish"] and "streaming": {"partials": true}, while the host returns contract 0.3, includes translate (and should include respond, see F1), and reports partials: false. The DictateOptions mode table (reference.md:33) and the output_language row (reference.md:35) omit respond and say output_language is "rejected for other modes", although respond accepts it. reference.md:182 still lists "Translate and rewrite modes" as out of scope. docs/openapi.yaml:7 sends readers to a contract.md that does not exist, and its Capabilities/DictateResult schemas lack output_languages, speeds, tools, models.mt and timings_ms.translate/respond, all of which the host returns (the demo page reads output_languages and speeds).
  • Conditions: a client generated from openapi.yaml, or one written from the reference tables.
  • Impact: generated clients cannot see the new fields, and a developer following the option table treats output_language on respond as invalid and never learns respond exists from the documented schema.
  • Fix: update the example and tables to the real response, remove the stale out-of-scope entries, point the openapi description at reference.md, and add the new capability/result fields to the schemas.

@agent-ci-infra-bot

Copy link
Copy Markdown

Important

Needs a person (1): Decide whether phase 1 may include respond mode and the opt-in lookup egress; if yes, require AGENTS.md and the phase-1…. Summary at the end.

PR #2 adds the phase-1 personal host: a FastAPI voice-session service (host/sessions), an env-driven model router, local worker scripts, a demo page, and the client API docs. I reviewed the full diff at 48c7096, ran python -m pytest -q host on it (38 passed, matching the PR's claim) and probed the endpoints with mock backends; the dictation/polish paths are carefully guarded, but the new respond mode is invisible in /v1/capabilities and its answers are silently truncated, and the head commit has no check runs or statuses, so CI itself has not reported. No earlier bot review exists (first review); relevance is current — main is still at the PR base 86dea21 and no linked Issue changed the requirements. This PR also edits .github/workflows/ci.yml, which a human maintainer must review and merge.

Labels: enhancement (a new phase-1 host capability; this repository has no type/priority axes, only GitHub defaults).

[Needs a person] F5 — medium, human decision, scope — Respond mode and its off-device lookups go beyond the phase-1 scope declared in AGENTS.md

  • Where: host/sessions/app.py (respond(), tools.py), host/sessions/tools.py, docs/integrating.md:11 ("The four modes").
  • Background: AGENTS.md states "Phase 1 scope is ASR + real-time translation only" and "Local First: no voice data or personal knowledge leaves the device unless the user opts in to a cloud provider for that stage." This PR adds an assistant mode (ask, rewrite, follow-ups, streamed answers) and two network lookups (wttr.in, Wikipedia) that are enabled by a host operator environment variable (OPENVOICE_TOOLS=1), not by a per-request or per-user opt-in. The PR description acknowledges that respond mode goes beyond AGENTS.md and says it was included deliberately.
  • Why a person must decide: merging this as-is makes the repository's declared phase-1 scope disagree with its code, and it introduces the project's first data-egress path without a user-facing consent control. Whether that is acceptable for phase 1 is a product/privacy decision, not something a review can settle. The PR description also leaves the repository licence open (no LICENSE file; the clean-up prompt is adapted from Apache-2.0 Voxt with attribution in prompts/NOTICE), which needs a maintainer decision before third-party-derived content lands.
  • Options:
    1. (recommended) Accept respond for phase 1 and update AGENTS.md plus the phase-1 scope wording in docs/subsystems/README.md/reference.md in this PR, keeping OPENVOICE_TOOLS off by default and documenting that enabling it is the user's decision. Pros: keeps the working, tested feature and makes the repository's rules match the code; cons: widens phase 1 and needs the privacy/licence wording agreed before merge.
    2. Keep this PR within the declared scope (dictation + translation) and move respond mode, streaming and tools to a follow-up PR. Pros: matches AGENTS.md exactly, smaller review, and the egress decision gets its own discussion; cons: splits a tested feature and the follow-up has to rebase on this work.

Reviewed commit: 48c7096
Coverage: PR #2; 33 changed file(s)

Needs a person (1)

  1. Decide whether phase 1 may include respond mode and the opt-in lookup egress; if yes, require AGENTS.md and the phase-1 docs to be updated in this PR, otherwise ask for respond and its tools to move to a follow-up PR.

@agent-ci-infra-bot agent-ci-infra-bot Bot added enhancement New feature or request bot-reviewed labels Dec 3, 2026
aliparchekan added a commit to aliparchekan/OpenVoice that referenced this pull request Dec 3, 2026
…s-free listening, tools and speaker labels

Everything runs on one Mac with local models; nothing leaves the device.

Host (FastAPI, `python -m host.sessions`), API contract 0.6 in docs/reference.md:
- POST /v1/dictate (also ?stream=1), /v1/translate, /v1/respond, /v1/confirm;
  WebSocket /v1/dictate/stream and /v1/listen; /v1/capabilities, /v1/health;
  a demo page at /demo.
- Router: each stage (speech, fast speech, clean-up, translation) goes to a
  local OpenAI-compatible model server chosen by environment variables.
  Qwen3-ASR-1.7B (accurate) and a 4-bit build (fast), Qwen3-4B-Instruct-2507.
- Clean-up keeps the spoken language and skips the LLM for clean sentences;
  respond mode answers live, with follow-ups from the conversation.

Hands-free listening (/v1/listen):
- Silero VAD (MIT, bundled ONNX, CPU) finds each sentence; live partial text
  from the fast speech model while speaking; per-session conversation memory.
- vad.model chooses "silero" or "level" (the old loudness detector, for
  comparison); end_silence_ms sets the pause that ends a sentence.

Tools:
- The host is an MCP client (OPENVOICE_MCP, mcpServers format). Read-only tools
  run directly; any other tool asks first with a confirm event, answered by
  POST /v1/confirm or a spoken yes/no; no answer in 60 s is no.
- Example local server host/mcp_servers/mac.py: time, Shortcuts, links,
  reminders (relative and clock times).

Speaker labels (opt-in, speakers: true on /v1/listen):
- CAM++ zh/en (Apache-2.0, 28 MB ONNX via sherpa-onnx) labels each sentence
  S1, S2, ... in ~19 ms, alongside recognition; enrolled voices get a name.
- POST/GET/DELETE /v1/speakers: consented enrolment from ~15 s of speech,
  stored only as a voiceprint on the device.
- Measured and compared candidate models in docs/results/T20.md.

Quality and tests:
- host/eval: clean-up 16/16, respond 24/24, tool choice 10/10 on the 4-bit
  Qwen3-4B. 85 tests with faked backends (CI needs no models).

Squashes the former PRs ThinkFlowLab#2 and #3 and fork PRs #13
and #14 (backups: backup/* branches on aliparchekan/OpenVoice).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@agent-ci-infra-bot

Copy link
Copy Markdown

Project licence decision: Apache-2.0. The maintainers settled this in the project chat today (2026-12-03): Open Voice is licensed under the Apache License 2.0.

What that means for this PR, since it says "No licence file yet":

  1. Please add a root LICENSE with the full Apache-2.0 text (the standard file, including the appendix). The copyright line at the top should name ThinkFlowLab, not an individual; the maintainers can adjust the exact wording when they set the licence in the repository settings after merge.
  2. Keep host/sessions/prompts/LICENSE-Voxt and host/sessions/prompts/NOTICE as they are. Section 4 of Apache-2.0 requires the attribution notices to travel with the redistribution, so the adapted clean-up prompt's NOTICE must stay; it would also be worth one line in README.md under the licence section pointing at host/sessions/prompts/NOTICE for the third-party attribution.
  3. Third-party material this PR already relies on should be named in that NOTICE if it is not already: the ASCEND-derived evaluation excerpts (CC BY-SA 4.0) are mentioned, which is what we need. Anything else you added from another project should get the same treatment.

Nothing else in this PR changes because of the licence choice. If you would rather land LICENSE as a separate small PR, that is fine too, as long as the repository has one before this code is merged.

@aliparchekan

Copy link
Copy Markdown
Author

Included in #3, which now has the whole phase 1 host as one squashed commit. Closing this one so there is a single PR to review.

aliparchekan added a commit to aliparchekan/OpenVoice that referenced this pull request Dec 3, 2026
…s-free listening, tools and speaker labels

Everything runs on one Mac with local models; nothing leaves the device.

Host (FastAPI, `python -m host.sessions`), API contract 0.6 in docs/reference.md:
- POST /v1/dictate (also ?stream=1), /v1/translate, /v1/respond, /v1/confirm;
  WebSocket /v1/dictate/stream and /v1/listen; /v1/capabilities, /v1/health;
  a demo page at /demo.
- Router: each stage (speech, fast speech, clean-up, translation) goes to a
  local OpenAI-compatible model server chosen by environment variables.
  Qwen3-ASR-1.7B (accurate) and a 4-bit build (fast), Qwen3-4B-Instruct-2507.
- Clean-up keeps the spoken language and skips the LLM for clean sentences;
  respond mode answers live, with follow-ups from the conversation.

Hands-free listening (/v1/listen):
- Silero VAD (MIT, bundled ONNX, CPU) finds each sentence; live partial text
  from the fast speech model while speaking; per-session conversation memory.
- vad.model chooses "silero" or "level" (the old loudness detector, for
  comparison); end_silence_ms sets the pause that ends a sentence.

Tools:
- The host is an MCP client (OPENVOICE_MCP, mcpServers format). Read-only tools
  run directly; any other tool asks first with a confirm event, answered by
  POST /v1/confirm or a spoken yes/no; no answer in 60 s is no.
- Example local server host/mcp_servers/mac.py: time, Shortcuts, links,
  reminders (relative and clock times).

Speaker labels (opt-in, speakers: true on /v1/listen):
- CAM++ zh/en (Apache-2.0, 28 MB ONNX via sherpa-onnx) labels each sentence
  S1, S2, ... in ~19 ms, alongside recognition; enrolled voices get a name.
- POST/GET/DELETE /v1/speakers: consented enrolment from ~15 s of speech,
  stored only as a voiceprint on the device.
- Measured and compared candidate models in docs/results/T20.md.

Quality and tests:
- host/eval: clean-up 16/16, respond 24/24, tool choice 10/10 on the 4-bit
  Qwen3-4B. 85 tests with faked backends (CI needs no models).

Squashes the former PRs ThinkFlowLab#2 and #3 and fork PRs #13
and #14 (backups: backup/* branches on aliparchekan/OpenVoice).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
aliparchekan added a commit to aliparchekan/OpenVoice that referenced this pull request Dec 4, 2026
…s-free listening, tools and speaker labels

Everything runs on one Mac with local models; nothing leaves the device.

Host (FastAPI, `python -m host.sessions`), API contract 0.6 in docs/reference.md:
- POST /v1/dictate (also ?stream=1), /v1/translate, /v1/respond, /v1/confirm;
  WebSocket /v1/dictate/stream and /v1/listen; /v1/capabilities, /v1/health;
  a demo page at /demo.
- Router: each stage (speech, fast speech, clean-up, translation) goes to a
  local OpenAI-compatible model server chosen by environment variables.
  Qwen3-ASR-1.7B (accurate) and a 4-bit build (fast), Qwen3-4B-Instruct-2507.
- Clean-up keeps the spoken language and skips the LLM for clean sentences;
  respond mode answers live, with follow-ups from the conversation.

Hands-free listening (/v1/listen):
- Silero VAD (MIT, bundled ONNX, CPU) finds each sentence; live partial text
  from the fast speech model while speaking; per-session conversation memory.
- vad.model chooses "silero" or "level" (the old loudness detector, for
  comparison); end_silence_ms sets the pause that ends a sentence.

Tools:
- The host is an MCP client (OPENVOICE_MCP, mcpServers format). Read-only tools
  run directly; any other tool asks first with a confirm event, answered by
  POST /v1/confirm or a spoken yes/no; no answer in 60 s is no.
- Example local server host/mcp_servers/mac.py: time, Shortcuts, links,
  reminders (relative and clock times).

Speaker labels (opt-in, speakers: true on /v1/listen):
- CAM++ zh/en (Apache-2.0, 28 MB ONNX via sherpa-onnx) labels each sentence
  S1, S2, ... in ~19 ms, alongside recognition; enrolled voices get a name.
- POST/GET/DELETE /v1/speakers: consented enrolment from ~15 s of speech,
  stored only as a voiceprint on the device.
- In respond mode the model is told who spoke ([Speaker S1] ...) and whom it
  answered ([To S1] ...), so it keeps people's requests and likes apart.
- Measured and compared candidate models in docs/results/T20.md.

Quality and tests:
- host/eval: clean-up 16/16, respond 24/24, tool choice 10/10 on the 4-bit
  Qwen3-4B. 87 tests with faked backends (CI needs no models).

Squashes the former PRs ThinkFlowLab#2 and #3 and fork PRs #13
and #14 (backups: backup/* branches on aliparchekan/OpenVoice).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
aliparchekan added a commit to aliparchekan/OpenVoice that referenced this pull request Dec 4, 2026
…s-free listening, tools and speaker labels

Everything runs on one Mac with local models; nothing leaves the device.

Host (FastAPI, `python -m host.sessions`), API contract 0.6 in docs/reference.md:
- POST /v1/dictate (also ?stream=1), /v1/translate, /v1/respond, /v1/confirm;
  WebSocket /v1/dictate/stream and /v1/listen; /v1/capabilities, /v1/health;
  a demo page at /demo.
- Router: each stage (speech, fast speech, clean-up, translation) goes to a
  local OpenAI-compatible model server chosen by environment variables.
  Qwen3-ASR-1.7B (accurate) and a 4-bit build (fast), Qwen3-4B-Instruct-2507.
- Clean-up keeps the spoken language and skips the LLM for clean sentences;
  respond mode answers live, with follow-ups from the conversation.

Hands-free listening (/v1/listen):
- Silero VAD (MIT, bundled ONNX, CPU) finds each sentence; live partial text
  from the fast speech model while speaking; per-session conversation memory.
- vad.model chooses "silero" or "level" (the old loudness detector, for
  comparison); end_silence_ms sets the pause that ends a sentence.

Tools:
- The host is an MCP client (OPENVOICE_MCP, mcpServers format). Read-only tools
  run directly; any other tool asks first with a confirm event, answered by
  POST /v1/confirm or a spoken yes/no; no answer in 60 s is no.
- Example local server host/mcp_servers/mac.py: time, Shortcuts, links,
  reminders (relative and clock times).

Speaker labels (opt-in, speakers: true on /v1/listen):
- CAM++ zh/en (Apache-2.0, 28 MB ONNX via sherpa-onnx) labels each sentence
  S1, S2, ... in ~19 ms, alongside recognition; enrolled voices get a name.
- POST/GET/DELETE /v1/speakers: consented enrolment from ~15 s of speech,
  stored only as a voiceprint on the device.
- In respond mode the model is told who spoke ([Speaker S1] ...) and whom it
  answered ([To S1] ...), so it keeps people's requests and likes apart.
- Measured and compared candidate models in docs/results/T20.md.

Quality and tests:
- host/eval: clean-up 16/16, respond 24/24, tool choice 10/10 on the 4-bit
  Qwen3-4B. 87 tests with faked backends (CI needs no models).

Squashes the former PRs ThinkFlowLab#2 and #3 and fork PRs #13
and #14 (backups: backup/* branches on aliparchekan/OpenVoice).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
aliparchekan added a commit to aliparchekan/OpenVoice that referenced this pull request Dec 4, 2026
…-free listening, tools and speaker labels

Everything runs on one Mac with local models; nothing leaves the device.

Host (FastAPI, `python -m host.sessions`), API contract 0.6 in docs/reference.md:
- POST /v1/dictate (also ?stream=1), /v1/translate, /v1/respond, /v1/confirm;
  WebSocket /v1/dictate/stream and /v1/listen; /v1/capabilities, /v1/health;
  a demo page at /demo.
- Router: each stage (speech, fast speech, clean-up, translation) goes to a
  local OpenAI-compatible model server chosen by environment variables.
  Qwen3-ASR-1.7B (accurate) and a 4-bit build (fast), Qwen3-4B-Instruct-2507.
- Clean-up keeps the spoken language and skips the LLM for clean sentences;
  respond mode answers live, with follow-ups from the conversation.

Hands-free listening (/v1/listen):
- Silero VAD (MIT, bundled ONNX, CPU) finds each sentence; live partial text
  from the fast speech model while speaking; per-session conversation memory.
- vad.model chooses "silero" or "level" (the old loudness detector, for
  comparison); end_silence_ms sets the pause that ends a sentence.

Tools:
- The host is an MCP client (OPENVOICE_MCP, mcpServers format). Read-only tools
  run directly; any other tool asks first with a confirm event, answered by
  POST /v1/confirm or a spoken yes/no; no answer in 60 s is no.
- Example local server host/mcp_servers/mac.py: time, Shortcuts, links,
  reminders (relative and clock times).

Speaker labels (opt-in, speakers: true on /v1/listen):
- CAM++ zh/en (Apache-2.0, 28 MB ONNX via sherpa-onnx) labels each sentence
  S1, S2, ... in ~19 ms, alongside recognition; enrolled voices get a name.
- POST/GET/DELETE /v1/speakers: consented enrolment from ~15 s of speech,
  stored only as a voiceprint on the device.
- In respond mode the model is told who spoke ([Speaker S1] ...) and whom it
  answered ([To S1] ...), so it keeps people's requests and likes apart.
- Measured and compared candidate models in docs/results/T20.md.

Quality and tests:
- host/eval: clean-up 16/16, respond 24/24, tool choice 10/10 on the 4-bit
  Qwen3-4B. 87 tests with faked backends (CI needs no models).

Squashes the former PRs ThinkFlowLab#2 and #3 and fork PRs #13
and #14 (backups: backup/* branches on aliparchekan/OpenVoice).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
aliparchekan added a commit to aliparchekan/OpenVoice that referenced this pull request Dec 4, 2026
…-free listening, tools and speaker labels

Everything runs on one Mac with local models; nothing leaves the device.

Host (FastAPI, `python -m host.sessions`), API contract 0.6 in docs/reference.md:
- POST /v1/dictate (also ?stream=1), /v1/translate, /v1/respond, /v1/confirm;
  WebSocket /v1/dictate/stream and /v1/listen; /v1/capabilities, /v1/health;
  a demo page at /demo.
- Router: each stage (speech, fast speech, clean-up, translation) goes to a
  local OpenAI-compatible model server chosen by environment variables.
  Qwen3-ASR-1.7B (accurate) and a 4-bit build (fast), Qwen3-4B-Instruct-2507.
- Clean-up keeps the spoken language and skips the LLM for clean sentences;
  respond mode answers live, with follow-ups from the conversation.
- Translation drops spoken fillers (um, uh, ah, er, hmm, 呃, 嗯) before
  translating, by a fixed rule with no added time; "clean_up": false keeps
  them. raw always keeps every word.

Hands-free listening (/v1/listen):
- Silero VAD (MIT, bundled ONNX, CPU) finds each sentence; live partial text
  from the fast speech model while speaking; per-session conversation memory.
- vad.model chooses "silero" or "level" (the old loudness detector, for
  comparison); end_silence_ms sets the pause that ends a sentence.

Tools:
- The host is an MCP client (OPENVOICE_MCP, mcpServers format). Read-only tools
  run directly; any other tool asks first with a confirm event, answered by
  POST /v1/confirm or a spoken yes/no; no answer in 60 s is no.
- Example local server host/mcp_servers/mac.py: time, Shortcuts, links,
  reminders (relative and clock times).

Speaker labels (opt-in, speakers: true on /v1/listen):
- Nemotron-3-Diarization (OpenMDW-1.1, Q8 GGUF via NeMo-Speech.cpp), when
  OPENVOICE_DIAR_LIB and OPENVOICE_DIAR_MODEL are set: the whole session
  streams into one diarizer and each sentence takes the speaker who talked
  most; "also" lists anyone who talked over them. Keeps people apart over a
  whole meeting (AMI EN2002a, 36 min: 18.3% DER vs 45.8% per-sentence CAM++).
  No added wait (median speech end to transcript 480 ms vs 525 ms off),
  ~20% of one CPU core.
- CAM++ zh/en (Apache-2.0, 28 MB ONNX via sherpa-onnx), the fallback: labels
  each sentence S1, S2, ... in ~19 ms; enrolled voices get a name.
- POST/GET/DELETE /v1/speakers: consented enrolment from ~15 s of speech,
  stored only as a voiceprint on the device.
- In respond mode the model is told who spoke ([Speaker S1] ...) and whom it
  answered ([To S1] ...), so it keeps people's requests and likes apart.
- Measured and compared candidate models in docs/results/T20.md.

Quality and tests:
- host/eval: clean-up 16/16, respond 24/24, tool choice 10/10 on the 4-bit
  Qwen3-4B. 100 tests with faked backends (CI needs no models).
- CI keeps opentelemetry-api below 1.46: 1.46.0 breaks FastAPI 0.165.1's
  request telemetry (every request fails with a TypeError).

Squashes the former PRs ThinkFlowLab#2 and #3 and fork PRs #13
and #14 (backups: backup/* branches on aliparchekan/OpenVoice).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
aliparchekan added a commit to aliparchekan/OpenVoice that referenced this pull request Dec 4, 2026
…-free listening, tools and speaker labels

Everything runs on one Mac with local models; nothing leaves the device.

Host (FastAPI, `python -m host.sessions`), API contract 0.6 in docs/reference.md:
- POST /v1/dictate (also ?stream=1), /v1/translate, /v1/respond, /v1/confirm;
  WebSocket /v1/dictate/stream and /v1/listen; /v1/capabilities, /v1/health;
  a demo page at /demo.
- Without a token (loopback only) the host serves only its own pages: a
  foreign Origin, or a Host other than 127.0.0.1/localhost/[::1], gets
  403 forbidden_origin, so no web page can drive it (incl. DNS rebinding).
- Router: each stage (speech, fast speech, clean-up, translation) goes to a
  local OpenAI-compatible model server chosen by environment variables.
  Qwen3-ASR-1.7B (accurate) and a 4-bit build (fast), Qwen3-4B-Instruct-2507.
- Clean-up keeps the spoken language and skips the LLM for clean sentences;
  respond mode answers live, with follow-ups from the conversation.
- Translation drops spoken fillers (um, uh, ah, er, hmm, 呃, 嗯) before
  translating, by a fixed rule with no added time; "clean_up": false keeps
  them. raw always keeps every word.

Hands-free listening (/v1/listen):
- Silero VAD (MIT, bundled ONNX, CPU) finds each sentence; live partial text
  from the fast speech model while speaking; per-session conversation memory.
- vad.model chooses "silero" or "level" (the old loudness detector, for
  comparison); end_silence_ms sets the pause that ends a sentence.

Tools:
- The host is an MCP client (OPENVOICE_MCP, mcpServers format). Read-only tools
  run directly; any other tool asks first with a confirm event, answered by
  POST /v1/confirm or a spoken yes/no; no answer in 60 s is no. There is no
  way to turn asking off. A spoken answer with any negation ("okay no,
  cancel that") is a no; 嗯 is not a yes.
- Only the tools offered in a turn can run (built-in web tools need
  OPENVOICE_TOOLS=1); the last round offers none, so there is always an answer.
- Example local server host/mcp_servers/mac.py: time, Shortcuts, links,
  reminders (relative and clock times).

Speaker labels (opt-in, speakers: true on /v1/listen):
- Nemotron-3-Diarization (OpenMDW-1.1, Q8 GGUF via NeMo-Speech.cpp), when
  OPENVOICE_DIAR_LIB and OPENVOICE_DIAR_MODEL are set: the whole session
  streams into one diarizer and each sentence takes the speaker who talked
  most; "also" lists anyone who talked over them. Keeps people apart over a
  whole meeting (AMI EN2002a, 36 min: 18.3% DER vs 45.8% per-sentence CAM++).
  No added wait (median speech end to transcript 480 ms vs 525 ms off),
  ~20% of one CPU core.
- CAM++ zh/en (Apache-2.0, 28 MB ONNX via sherpa-onnx), the fallback: labels
  each sentence S1, S2, ... in ~19 ms; enrolled voices get a name.
- POST/GET/DELETE /v1/speakers: consented enrolment from ~15 s of speech,
  stored only as a voiceprint on the device.
- In respond mode the model is told who spoke ([Speaker S1] ...) and whom it
  answered ([To S1] ...), so it keeps people's requests and likes apart.
- Measured and compared candidate models in docs/results/T20.md.

Quality and tests:
- host/eval: clean-up 16/16, respond 24/24, tool choice 10/10 on the 4-bit
  Qwen3-4B. 112 tests with faked backends (CI needs no models).
- CI keeps opentelemetry-api below 1.46: 1.46.0 breaks FastAPI 0.165.1's
  request telemetry (every request fails with a TypeError).

Licence: Apache-2.0 (LICENSE), with NOTICE listing the bundled Silero VAD,
the adapted clean-up prompt, ASCEND excerpts and the optional speaker models.

Squashes the former PRs ThinkFlowLab#2 and #3 and fork PRs #13
and #14 (backups: backup/* branches on aliparchekan/OpenVoice).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
aliparchekan added a commit to aliparchekan/OpenVoice that referenced this pull request Dec 4, 2026
…-free listening, tools and speaker labels

Everything runs on one Mac with local models; nothing leaves the device.

Host (FastAPI, `python -m host.sessions`), API contract 0.6 in docs/reference.md:
- POST /v1/dictate (also ?stream=1), /v1/translate, /v1/respond, /v1/confirm;
  WebSocket /v1/dictate/stream and /v1/listen; /v1/capabilities, /v1/health;
  a demo page at /demo.
- Without a token (loopback only) the host serves only its own pages: a
  foreign Origin, or a Host other than 127.0.0.1/localhost/[::1], gets
  403 forbidden_origin, so no web page can drive it (incl. DNS rebinding).
- Router: each stage (speech, fast speech, clean-up, translation) goes to a
  local OpenAI-compatible model server chosen by environment variables.
  Qwen3-ASR-1.7B (accurate) and a 4-bit build (fast), Qwen3-4B-Instruct-2507.
- Clean-up keeps the spoken language and skips the LLM for clean sentences;
  respond mode answers live, with follow-ups from the conversation.
- Translation drops spoken fillers (um, uh, ah, er, hmm, 呃, 嗯) before
  translating, by a fixed rule with no added time; "clean_up": false keeps
  them. raw always keeps every word.
- Spoken self-corrections are resolved in polish and translate: "Book me a
  meeting at 2 p.m. No, 3 p.m." gives "...at 3 p.m.", "七点...不对,不对...
  八点钟" gives "八点钟". A correction word (no, sorry, I mean, actually, 不对,
  哦不...) sends the sentence to the clean-up model; the guard lets a
  correction delete words but not add any, drop a negation, or only drop
  "sorry"/"actually". 30/33 probe sentences, 12/12 look-alikes kept.
  Transcribe and raw stay verbatim.

Hands-free listening (/v1/listen):
- Silero VAD (MIT, bundled ONNX, CPU) finds each sentence; live partial text
  from the fast speech model while speaking; per-session conversation memory.
- vad.model chooses "silero" or "level" (the old loudness detector, for
  comparison); end_silence_ms sets the pause that ends a sentence.

Tools:
- The host is an MCP client (OPENVOICE_MCP, mcpServers format). Read-only tools
  run directly; any other tool asks first with a confirm event, answered by
  POST /v1/confirm or a spoken yes/no; no answer in 60 s is no. There is no
  way to turn asking off. A spoken answer with any negation ("okay no,
  cancel that") is a no; 嗯 is not a yes.
- Only the tools offered in a turn can run (built-in web tools need
  OPENVOICE_TOOLS=1); the last round offers none, so there is always an answer.
- Example local server host/mcp_servers/mac.py: time, Shortcuts, links,
  reminders (relative and clock times).

Speaker labels (opt-in, speakers: true on /v1/listen):
- Nemotron-3-Diarization (OpenMDW-1.1, Q8 GGUF via NeMo-Speech.cpp), when
  OPENVOICE_DIAR_LIB and OPENVOICE_DIAR_MODEL are set: the whole session
  streams into one diarizer and each sentence takes the speaker who talked
  most; "also" lists anyone who talked over them. Keeps people apart over a
  whole meeting (AMI EN2002a, 36 min: 18.3% DER vs 45.8% per-sentence CAM++).
  No added wait (median speech end to transcript 480 ms vs 525 ms off),
  ~20% of one CPU core.
- CAM++ zh/en (Apache-2.0, 28 MB ONNX via sherpa-onnx), the fallback: labels
  each sentence S1, S2, ... in ~19 ms; enrolled voices get a name.
- POST/GET/DELETE /v1/speakers: consented enrolment from ~15 s of speech,
  stored only as a voiceprint on the device.
- In respond mode the model is told who spoke ([Speaker S1] ...) and whom it
  answered ([To S1] ...), so it keeps people's requests and likes apart.
- Measured and compared candidate models in docs/results/T20.md.

Quality and tests:
- host/eval: clean-up 21/22, respond 24/24, tool choice 10/10 on the 4-bit
  Qwen3-4B. 145 tests with faked backends (CI needs no models).
- CI keeps opentelemetry-api below 1.46: 1.46.0 breaks FastAPI 0.165.1's
  request telemetry (every request fails with a TypeError).

Licence: Apache-2.0 (LICENSE), with NOTICE listing the bundled Silero VAD,
the adapted clean-up prompt, ASCEND excerpts and the optional speaker models.

Squashes the former PRs ThinkFlowLab#2 and #3 and fork PRs #13
and #14 (backups: backup/* branches on aliparchekan/OpenVoice).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot-reviewed enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant