Commit Graph

2 Commits

Author SHA1 Message Date
王性驊 12c9944dee Server voice service: Whisper on the brain's own server, checked for real
`make server` now asks whether to run a voice service there (and the
kept-setup menu can add or remove it): speaches, Whisper
large-v3-turbo on the CPU, behind the brain only (no published port),
enabled with COMPOSE_PROFILES=voice so it composes with the Tailscale
and LAN files. The brain sees ANYBOT_VOICE_URL, fills 設定 › 語音 › 聽
with it once (what is changed later stays), and asks the service for
its model at each start: this build downloads only when asked (it has
no PRELOAD_MODELS, and the 0.8.2-cpu tag is older still, so the image
is pinned by the digest that was tested).

Tested end to end on 12 CPU cores with the compose file itself: first
start 404 s to download the model, later starts 1 s; 11 s of Mandarin
mixed with English (Chrome, Tesla FSD) in 3.4–3.6 s, every word right.
small is three times faster and slipped a character. Reading aloud
stays with another service: speaches can't say Chinese (its espeak has
no "zh"), English works.

From the same test: a service that answers 200 with no sound is now an
error said in words (it was played as silence), Whisper's ASCII
punctuation in Chinese becomes full-width (,?!), and speaches'
"not installed locally" says the model is still on its way.
2026-11-11 00:14:50 +08:00
王性驊 40d1d9707a Voice: its own 設定 › 語音, run by the brain for every screen and the phone
Voice was three implementations that broke on their own: speech to text
borrowed the OpenAI key (so with only Grok set up the mic recorded,
then failed), OpenAI's models it hard-coded stop on 2027-02-26, read
aloud was macOS `say` or espeak-ng (silently nothing on Windows, where
espeak isn't installed), and the phone used the browser's own
recognition. Now:

- 設定 › 語音 has 聽 and 說, each a service: off, OpenAI-compatible
  (OpenAI, Groq, a Whisper server of your own: the address decides),
  xAI or ElevenLabs. An empty key borrows 設定 › 模型's for the same
  service. Each side says 可以用 or what it lacks; 聽 has 試試看
  (record a sentence, show what was heard), 說 has 試聽 and the voice
  list. speech.rs does the calls; xAI's both ways were checked for real
  (Mandarin read, then heard back, in Traditional characters).
- The brain does it all: the phone POSTs its recording (MediaRecorder)
  to /api/voice/transcribe, screens to /api/sync/voice/transcribe;
  answers come back as MP3 from …/voice/speech and are played on the
  device (rodio; an <audio> on the phone, 「唸出來」 in a message's
  menu). Keys stay on the brain (the voice keys are redacted for
  screens like the others).
- No service, no voice anywhere: the mic, 語音聊天, 會議錄音 and 朗讀
  only appear once 聽 (and 說) can be called; the phone's state says
  which. Without voice the send arrow just rests where 語音聊天 was.
- 會議錄音 is uploaded to the brain, which turns it into text in the
  background and hands it to the bot itself: a meeting is longer than
  the 35 s the account lets a request wait, and a brain on a server has
  no window (the jobs are polled in background()).
- Recognisers answer Mandarin in Simplified: in a Traditional Chinese
  window or phone the text becomes Traditional with Taiwan wording.
- Older saves: whoever had an OpenAI key keeps voice input (聽 =
  OpenAI); everyone else starts with it off. Bots' macOS voice names
  are cleared. 對話詳細資訊's 加入會議 started plain voice input; it
  starts a meeting now.
2026-11-10 22:58:18 +08:00