@7ots/cli 0.1.13 → 0.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/lib/brain.mjs +6 -1
- package/cli/lib/pet-server.mjs +8 -5
- package/cli/pet/pet.html +8 -5
- package/cli/pet/settings.html +9 -3
- package/package.json +1 -1
- package/server/tts.mjs +2 -1
- package/src/voice/tags.js +30 -0
package/cli/lib/brain.mjs
CHANGED
|
@@ -18,6 +18,7 @@ import { createLLM } from '../../server/llm.mjs';
|
|
|
18
18
|
import { env, loadConfig, ORQUESTA_URL } from './config.mjs';
|
|
19
19
|
import { characterPrompt, integrationsPrompt } from './integrations.mjs';
|
|
20
20
|
import { ensureHome, PET_PORT } from './paths.mjs';
|
|
21
|
+
import { SPEECH_TAGS_PROMPT } from '../../src/voice/tags.js';
|
|
21
22
|
|
|
22
23
|
// Started from a desktop launcher or autostart, the daemon gets a bare PATH (/usr/bin:/bin) and can't find
|
|
23
24
|
// CLIs installed per user (claude lives in ~/.local/bin): add the usual places before looking for them.
|
|
@@ -47,6 +48,9 @@ export function detectClis() {
|
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
/** System prompt shared by every brain. */
|
|
51
|
+
/** Voices that perform speech tags: xAI, and ElevenLabs on its v3 model. */
|
|
52
|
+
export const expressiveVoice = (v = {}) => v.kind === 'grok' || (v.kind === 'elevenlabs' && /v3/.test(v.providers?.elevenlabs?.model || ''));
|
|
53
|
+
|
|
50
54
|
export function petSystem(identity, { lang, role = 'pet' } = {}) {
|
|
51
55
|
const L = LANG_NAME[lang || identity.language] || 'English';
|
|
52
56
|
const base = identityPrompt(identity, 'en');
|
|
@@ -64,8 +68,9 @@ export function petSystem(identity, { lang, role = 'pet' } = {}) {
|
|
|
64
68
|
} catch {}
|
|
65
69
|
const sheet = characterPrompt(config.character);
|
|
66
70
|
const tools = role === 'assistant' ? integrationsPrompt(config) : '';
|
|
71
|
+
const tone = config.voice?.expressive && expressiveVoice(config.voice) ? `\n${SPEECH_TAGS_PROMPT}` : '';
|
|
67
72
|
// 'auto': the language the human just wrote in (they may switch from the ot's usual one)
|
|
68
|
-
return `${base}${sheet ? `\n${sheet}` : ''}\n${job}${tools ? `\n${tools}` : ''}\n${lang === 'auto' ? 'Always answer in the language your human writes in.' : `Always answer in ${L}.`}`;
|
|
73
|
+
return `${base}${sheet ? `\n${sheet}` : ''}\n${job}${tools ? `\n${tools}` : ''}${tone}\n${lang === 'auto' ? 'Always answer in the language your human writes in.' : `Always answer in ${L}.`}`;
|
|
69
74
|
}
|
|
70
75
|
|
|
71
76
|
function runCli({ cli, model, command }, prompt, timeoutMs, files) {
|
package/cli/lib/pet-server.mjs
CHANGED
|
@@ -65,6 +65,7 @@ import { defineIdentity, GROK_VOICES, OPENAI_VOICES, TTS_MODELS } from '../../sr
|
|
|
65
65
|
import { normalizeMod, normalizeMods, MAX_MODS } from '../../src/character/mods.js';
|
|
66
66
|
import { MOD_CATALOG } from '../../src/character/mods/index.js';
|
|
67
67
|
import { DANCES } from '../../src/character/motion.js';
|
|
68
|
+
import { stripSpeechTags } from '../../src/voice/tags.js';
|
|
68
69
|
|
|
69
70
|
/** Mods importados en este pet (~/.7ots/mods/library.json), normalizados. */
|
|
70
71
|
// scenes between ots on the same desktop (pet/electron/director.cjs plays them)
|
|
@@ -690,7 +691,7 @@ export function startPetServer({ port = PET_PORT, log = () => {} } = {}) {
|
|
|
690
691
|
if (['none', 'browser'].includes(kind)) return json(501, { error: 'browser voice' });
|
|
691
692
|
try {
|
|
692
693
|
if (kind === 'local') {
|
|
693
|
-
const { audio, contentType } = await synthesizeLocal(
|
|
694
|
+
const { audio, contentType } = await synthesizeLocal(stripSpeechTags(data.text).slice(0, 600), { lang });
|
|
694
695
|
return res.writeHead(200, { 'Content-Type': contentType }).end(audio);
|
|
695
696
|
}
|
|
696
697
|
const { synthesize } = await import('../../server/tts.mjs');
|
|
@@ -827,7 +828,7 @@ export function startPetServer({ port = PET_PORT, log = () => {} } = {}) {
|
|
|
827
828
|
let mods = normalizeMods(ch.mods);
|
|
828
829
|
if (data.remove) mods = mods.filter((m) => m.id !== data.remove);
|
|
829
830
|
if (data.add || data.mod) {
|
|
830
|
-
const m = data.add ? MOD_CATALOG.find((c) => c.id === data.add) : data.mod;
|
|
831
|
+
const m = data.add ? MOD_CATALOG.find((c) => c.id === data.add) || modLibrary().find((c) => c.id === data.add) : data.mod; // catalog, or one imported earlier
|
|
831
832
|
const n = m && normalizeMod(m);
|
|
832
833
|
if (!n) return [400, { error: 'mod' }];
|
|
833
834
|
if (!mods.some((x) => x.id === n.id) && mods.length >= MAX_MODS) return [400, { error: 'maxMods' }];
|
|
@@ -1095,9 +1096,11 @@ ${keys.map((k) => FIELDS[k]).join('\n')}`;
|
|
|
1095
1096
|
if (d.screen?.every !== undefined) next.screen.every = Math.max(1, Math.min(60, Math.round(Number(d.screen.every)) || 5));
|
|
1096
1097
|
let reload = false;
|
|
1097
1098
|
if (d.voice) {
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1099
|
+
const vk = d.voice.kind ?? next.voice.kind;
|
|
1100
|
+
if (!['none', 'browser', 'local', 'elevenlabs', 'openai', 'apuchat', 'grok', 'fish'].includes(vk)) return 'voice';
|
|
1101
|
+
reload = vk !== next.voice.kind;
|
|
1102
|
+
next.voice = { ...next.voice, kind: vk };
|
|
1103
|
+
if (d.voice.expressive !== undefined) next.voice.expressive = !!d.voice.expressive;
|
|
1101
1104
|
// each provider's own voice, model and style ({ elevenlabs: { voiceId, model }, openai: { voiceId, model, style } … })
|
|
1102
1105
|
const pv = d.voice.providers;
|
|
1103
1106
|
if (pv && typeof pv === 'object') {
|
package/cli/pet/pet.html
CHANGED
|
@@ -579,10 +579,10 @@
|
|
|
579
579
|
const an = ctx.createAnalyser();
|
|
580
580
|
src.connect(an);
|
|
581
581
|
an.connect(ctx.destination);
|
|
582
|
-
const stop = ch.lipsync?.(an, { text });
|
|
582
|
+
const stop = ch.lipsync?.(an, { text: clean(text) });
|
|
583
583
|
if (stop) return void (lip = { stop });
|
|
584
584
|
} catch {}
|
|
585
|
-
talk(true, text, (audio.duration || 0) * 1000);
|
|
585
|
+
talk(true, clean(text), (audio.duration || 0) * 1000);
|
|
586
586
|
};
|
|
587
587
|
audio.onended = audio.onerror = () => talk(false);
|
|
588
588
|
return await audio.play();
|
|
@@ -590,7 +590,7 @@
|
|
|
590
590
|
} catch {}
|
|
591
591
|
}
|
|
592
592
|
if (!('speechSynthesis' in window)) return;
|
|
593
|
-
const u = new SpeechSynthesisUtterance(text);
|
|
593
|
+
const u = new SpeechSynthesisUtterance(clean(text));
|
|
594
594
|
u.lang = id.voice?.lang || lang;
|
|
595
595
|
u.rate = id.voice?.rate || 1;
|
|
596
596
|
u.pitch = id.voice?.pitch || 1;
|
|
@@ -631,13 +631,16 @@
|
|
|
631
631
|
}
|
|
632
632
|
ch.gesture(Math.random() < 0.5 ? 'nod' : 'wiggle');
|
|
633
633
|
}
|
|
634
|
-
|
|
634
|
+
// speech tags ([laugh], <whisper>…: settings → Voice → expressions) go to the voice, never to the bubble (as src/voice/tags.js)
|
|
635
|
+
const clean = (t) => String(t ?? '').replace(/<\/?(loud|soft|whisper|fast|slow|singing)>/gi, '').replace(/\s*\[(pause|long-pause|laugh|cry|mouth-click|breath|sigh)\]\s*/gi, ' ').replace(/\s{2,}/g, ' ').trim();
|
|
636
|
+
function say(raw, withFace = false) {
|
|
637
|
+
const text = clean(raw);
|
|
635
638
|
showBubble(document.createTextNode(text), Math.max(4500, text.length * 90));
|
|
636
639
|
talk(true, text); // the mouth moves with the words even without a voice; a real voice re-syncs it
|
|
637
640
|
clearTimeout(say.t);
|
|
638
641
|
say.t = setTimeout(() => talk(false), 500 + text.length * 60);
|
|
639
642
|
if (withFace) react(text);
|
|
640
|
-
speak(
|
|
643
|
+
speak(raw);
|
|
641
644
|
}
|
|
642
645
|
// It asks before acting for you (Orquesta…): Approve / Reject in the bubble, answered on POST /approve.
|
|
643
646
|
let asking = null;
|
package/cli/pet/settings.html
CHANGED
|
@@ -258,6 +258,7 @@
|
|
|
258
258
|
<section aria-labelledby="hVoice">
|
|
259
259
|
<h2 id="hVoice" data-t="voiceH"></h2>
|
|
260
260
|
<p class="hint" data-t="voiceHint"></p>
|
|
261
|
+
<div id="vExpr"></div>
|
|
261
262
|
<div class="opts" id="voices"></div>
|
|
262
263
|
<div class="row">
|
|
263
264
|
<button class="primary" id="saveVoice" data-t="save"></button>
|
|
@@ -376,7 +377,7 @@
|
|
|
376
377
|
accH: 'Your 7ots account', accHint: 'Connect it to pick which of your ots lives on this computer, and bring its look, voice and personality from 7ots.com.',
|
|
377
378
|
connect: 'Connect with 7ots.com', connecting: 'Waiting for you in the browser…', openAgain: 'Didn’t open? Open the page', signedAs: 'Connected as {who}', logout: 'Disconnect', noOts: 'No ots in your account yet.', newOt: 'Create one on 7ots.com',
|
|
378
379
|
useThis: 'Use this one', current: 'On this computer', switching: 'Switching…', resync: 'Sync again', restarting: 'Restarting with {name}…', heroH: 'Bring your ots home', heroP: 'Sign in once and choose which of your ots lives on this computer.', perkLook: 'Look', perkVoice: 'Voice', perkMind: 'Personality', heroNote: 'Opens 7ots.com in your browser: press Connect there and come back.', cancel: 'Cancel', connectedAs: 'Connected as', yourOts: 'Your ots', slow: 'Taking a while… still restarting.', card: 'Card', invite: 'Also on this computer', dismiss: 'Turn off', visiting: 'Also active', maxOts: 'Two at a time for now',
|
|
379
|
-
voiceH: 'Voice', voiceHint: 'How it speaks out loud, and how it hears you (🎙️ in its menu or Ctrl+Alt+Space).',
|
|
380
|
+
voiceH: 'Voice', vExpr: 'Expressions', vExprHint: 'It picks its own tone: laughs, sighs, whispers, a sad or excited voice. Works with Grok (xAI) and ElevenLabs v3; other voices just skip them.', voiceHint: 'How it speaks out loud, and how it hears you (🎙️ in its menu or Ctrl+Alt+Space).',
|
|
380
381
|
vnone: 'Silent', vnoneD: 'Only speech bubbles.', vbrowser: 'System voice', vbrowserD: 'The browser’s speech synthesis. Often has no voices on Linux.',
|
|
381
382
|
vlocal: 'Local voice (Piper)', vlocalD: 'Runs on this computer, free and private. Picks Spanish or English per line.', vlocalNo: 'not installed (7ots voice install)',
|
|
382
383
|
velevenlabs: 'ElevenLabs', velevenlabsD: 'Natural cloud voices, with your key.', vopenai: 'OpenAI', vopenaiD: 'OpenAI text-to-speech, with your key.',
|
|
@@ -410,7 +411,7 @@
|
|
|
410
411
|
accH: 'Tu cuenta 7ots', accHint: 'Conéctala para elegir cuál de tus ots vive en este computador, y traer su aspecto, voz y personalidad desde 7ots.com.',
|
|
411
412
|
connect: 'Conectar con 7ots.com', connecting: 'Esperándote en el navegador…', openAgain: '¿No se abrió? Abrir la página', signedAs: 'Conectado como {who}', logout: 'Desconectar', noOts: 'Todavía no hay ots en tu cuenta.', newOt: 'Crea uno en 7ots.com',
|
|
412
413
|
useThis: 'Usar este', current: 'En este computador', switching: 'Cambiando…', resync: 'Sincronizar', restarting: 'Reiniciando con {name}…', heroH: 'Trae a tus ots a casa', heroP: 'Inicia sesión una vez y elige cuál de tus ots vive en este computador.', perkLook: 'Aspecto', perkVoice: 'Voz', perkMind: 'Personalidad', heroNote: 'Abre 7ots.com en tu navegador: aprieta Conectar ahí y vuelve.', cancel: 'Cancelar', connectedAs: 'Conectado como', yourOts: 'Tus ots', slow: 'Está tardando… sigue reiniciando.', card: 'Tarjeta', invite: 'Activar también aquí', dismiss: 'Desactivar', visiting: 'También activo', maxOts: 'Por ahora, dos a la vez',
|
|
413
|
-
voiceH: 'Voz', voiceHint: 'Cómo habla en voz alta, y cómo te escucha (🎙️ en su menú o Ctrl+Alt+Espacio).',
|
|
414
|
+
voiceH: 'Voz', vExpr: 'Expresiones', vExprHint: 'Elige su propio tono: risas, suspiros, susurros, voz triste o emocionada. Funciona con Grok (xAI) y ElevenLabs v3; las otras voces las omiten.', voiceHint: 'Cómo habla en voz alta, y cómo te escucha (🎙️ en su menú o Ctrl+Alt+Espacio).',
|
|
414
415
|
vnone: 'Mudo', vnoneD: 'Solo globos de texto.', vbrowser: 'Voz del sistema', vbrowserD: 'La síntesis del navegador. En Linux suele no tener voces.',
|
|
415
416
|
vlocal: 'Voz local (Piper)', vlocalD: 'Corre en este computador, gratis y privada. Elige español o inglés por frase.', vlocalNo: 'no instalada (7ots voice install)',
|
|
416
417
|
velevenlabs: 'ElevenLabs', velevenlabsD: 'Voces naturales en la nube, con tu key.', vopenai: 'OpenAI', vopenaiD: 'Texto a voz de OpenAI, con tu key.',
|
|
@@ -444,7 +445,7 @@
|
|
|
444
445
|
accH: 'Sua conta 7ots', accHint: 'Conecte para escolher qual dos seus ots vive neste computador, e trazer visual, voz e personalidade do 7ots.com.',
|
|
445
446
|
connect: 'Conectar com 7ots.com', connecting: 'Esperando você no navegador…', openAgain: 'Não abriu? Abrir a página', signedAs: 'Conectado como {who}', logout: 'Desconectar', noOts: 'Ainda não há ots na sua conta.', newOt: 'Crie um no 7ots.com',
|
|
446
447
|
useThis: 'Usar este', current: 'Neste computador', switching: 'Trocando…', resync: 'Sincronizar', restarting: 'Reiniciando com {name}…', heroH: 'Traga seus ots para casa', heroP: 'Entre uma vez e escolha qual dos seus ots vive neste computador.', perkLook: 'Visual', perkVoice: 'Voz', perkMind: 'Personalidade', heroNote: 'Abre o 7ots.com no navegador: aperte Conectar lá e volte.', cancel: 'Cancelar', connectedAs: 'Conectado como', yourOts: 'Seus ots', slow: 'Está demorando… ainda reiniciando.', card: 'Carta', invite: 'Ativar também aqui', dismiss: 'Desativar', visiting: 'Também ativo', maxOts: 'Por enquanto, dois de cada vez',
|
|
447
|
-
voiceH: 'Voz', voiceHint: 'Como ele fala em voz alta, e como te ouve (🎙️ no menu ou Ctrl+Alt+Espaço).',
|
|
448
|
+
voiceH: 'Voz', vExpr: 'Expressões', vExprHint: 'Escolhe o próprio tom: risadas, suspiros, sussurros, voz triste ou animada. Funciona com Grok (xAI) e ElevenLabs v3; as outras vozes as ignoram.', voiceHint: 'Como ele fala em voz alta, e como te ouve (🎙️ no menu ou Ctrl+Alt+Espaço).',
|
|
448
449
|
vnone: 'Mudo', vnoneD: 'Só balões de texto.', vbrowser: 'Voz do sistema', vbrowserD: 'A síntese do navegador. No Linux costuma não ter vozes.',
|
|
449
450
|
vlocal: 'Voz local (Piper)', vlocalD: 'Roda neste computador, grátis e privada. Escolhe espanhol ou inglês por frase.', vlocalNo: 'não instalada (7ots voice install)',
|
|
450
451
|
velevenlabs: 'ElevenLabs', velevenlabsD: 'Vozes naturais na nuvem, com sua key.', vopenai: 'OpenAI', vopenaiD: 'Texto para voz da OpenAI, com sua key.',
|
|
@@ -1068,6 +1069,11 @@
|
|
|
1068
1069
|
opt('grok', [vkey('XAI_API_KEY', 'xAI ' + t('key'), S.voices.keys.grok), vconf('grok')]),
|
|
1069
1070
|
opt('fish', [vkey('FISH_API_KEY', 'Fish Audio ' + t('key'), S.voices.keys.fish), vconf('fish')]),
|
|
1070
1071
|
);
|
|
1072
|
+
// expressions: the brain picks the tone and marks it with speech tags the voice performs
|
|
1073
|
+
const ex = el('input', { type: 'checkbox', checked: !!S.config.voice?.expressive });
|
|
1074
|
+
const exMsg = el('span', { className: 'msg', role: 'status' });
|
|
1075
|
+
ex.addEventListener('change', () => save({ voice: { expressive: ex.checked } }, exMsg));
|
|
1076
|
+
$('#vExpr').replaceChildren(el('label', { className: 'chip' }, ex, t('vExpr')), ' ', el('small', { textContent: t('vExprHint') }), exMsg);
|
|
1071
1077
|
const stt = { local: t('sttLocal'), openai: 'OpenAI', elevenlabs: 'ElevenLabs' }[S.stt] || t('sttNone');
|
|
1072
1078
|
$('#stt').replaceChildren(t('sttNow'), ' ', el('b', { textContent: stt }));
|
|
1073
1079
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@7ots/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.14",
|
|
4
4
|
"description": "7ots.com — your AI companion with a face of its own: a desktop pet that watches over your coding agent (Claude Code and shell hooks), a personal assistant (reminders, alerts, notes, opens sites, sees your screen if allowed) and a reproducible identity (face, personality, voice) for any agent — in apuchat meet calls, Orquesta projects or your own server.",
|
|
5
5
|
"homepage": "https://7ots.com",
|
|
6
6
|
"repository": {
|
package/server/tts.mjs
CHANGED
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
|
|
29
29
|
import { OPENAI_VOICES } from './identity.mjs';
|
|
30
30
|
import { i18nError } from './i18n.mjs';
|
|
31
|
+
import { speechTagsFor } from '../src/voice/tags.js';
|
|
31
32
|
|
|
32
33
|
const PROVIDERS = ['apuchat', 'elevenlabs', 'grok', 'fish', 'openai'];
|
|
33
34
|
const TIMEOUT_MS = 20_000;
|
|
@@ -57,7 +58,7 @@ export function openaiTtsKey(env = process.env) {
|
|
|
57
58
|
|
|
58
59
|
export async function synthesize({ text, voice = {}, env = process.env }) {
|
|
59
60
|
const provider = PROVIDERS.includes(voice.provider) ? voice.provider : voice.provider === 'browser' ? 'none' : ttsProvider(env);
|
|
60
|
-
const input =
|
|
61
|
+
const input = speechTagsFor(text, provider, voice.model || (provider === 'elevenlabs' ? env.ELEVENLABS_MODEL : '')).slice(0, 1500);
|
|
61
62
|
if (!input) throw i18nError(400, 'server.tts.empty');
|
|
62
63
|
|
|
63
64
|
if (provider === 'apuchat') {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Speech tags: the brain marks tone ("expressions" in settings → Voice) and the voice performs it.
|
|
3
|
+
* xAI reads them as is; ElevenLabs v3 gets its own audio tags; every other voice (and the bubble) gets clean text.
|
|
4
|
+
*/
|
|
5
|
+
const INLINE = /\s*\[(pause|long-pause|laugh|cry|mouth-click|breath|sigh)\]\s*/gi;
|
|
6
|
+
const WRAP = /<\/?(loud|soft|whisper|fast|slow|singing)>/gi;
|
|
7
|
+
|
|
8
|
+
export function stripSpeechTags(text) {
|
|
9
|
+
return String(text ?? '').replace(WRAP, '').replace(INLINE, ' ').replace(/\s{2,}/g, ' ').trim();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const EL_INLINE = { laugh: '[laughs]', cry: '[crying]', sigh: '[sighs]', breath: '[exhales]', pause: '…', 'long-pause': '… …', 'mouth-click': '' };
|
|
13
|
+
const EL_WRAP = { whisper: '[whispers]', soft: '[softly]', loud: '[shouting]', slow: '[slowly]', fast: '[quickly]', singing: '[sings]' };
|
|
14
|
+
|
|
15
|
+
/** The text a provider should get: tags kept (xAI), translated (ElevenLabs v3) or removed. */
|
|
16
|
+
export function speechTagsFor(text, provider, model = '') {
|
|
17
|
+
if (provider === 'grok') return String(text ?? '');
|
|
18
|
+
if (provider === 'elevenlabs' && /v3/.test(model)) {
|
|
19
|
+
return String(text ?? '')
|
|
20
|
+
.replace(/<(loud|soft|whisper|fast|slow|singing)>/gi, (_, t) => `${EL_WRAP[t.toLowerCase()]} `)
|
|
21
|
+
.replace(/<\/(loud|soft|whisper|fast|slow|singing)>/gi, '')
|
|
22
|
+
.replace(/\[(pause|long-pause|laugh|cry|mouth-click|breath|sigh)\]/gi, (_, t) => EL_INLINE[t.toLowerCase()])
|
|
23
|
+
.replace(/\s{2,}/g, ' ')
|
|
24
|
+
.trim();
|
|
25
|
+
}
|
|
26
|
+
return stripSpeechTags(text);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const SPEECH_TAGS_PROMPT =
|
|
30
|
+
'Your words are spoken aloud by an expressive voice, and you choose the tone. When it fits (not in every line) add: [laugh], [sigh], [cry], [breath] or [pause] where the sound goes, or wrap words in <whisper>…</whisper>, <soft>…</soft>, <loud>…</loud>, <slow>…</slow> or <fast>…</fast>. Sad news sounds soft and slow, a joke gets a laugh. No other brackets or angle brackets.';
|