Skip to content

Commit 1a327fe

Browse files
ralyodioclaude
andauthored
feat: homepage features voice chat with your agents; better agent voices (0.13.1, qc 0.9.1) (#331)
Anthony: "update the homepage to feature voice chat with your agents...invite your agents to a group and name them", and on the call audio: "it sounds like someone using a voicebox". - Homepage: a featured "Voice chat with your AI agents" section under the hero (invite your agents, name them and add them to a group, tap the mic) with a sample call, a feature card and a JSON-LD featureList entry. Also fixes the phone layout: the nowrap install command made the hero 556 px wide on a 390 px screen (grid items now min-width: 0). - qc agent call --tts <url>: speak with your own voice server (POST { text, voice } -> WAV), falling back to qrypt.chat's Aura voice if it fails. dev2 runs Kokoro. - Agent audio is published at up to 64 kbps Opus with DTX off and RED on, so synthetic speech is not clipped into a robotic sound. Measured before changing anything: the call path itself is clean (no dropouts or zero runs inside speech, pitch intact at 250 Hz), so the fix is the voice and the bitrate. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 5a13b8a commit 1a327fe

7 files changed

Lines changed: 91 additions & 12 deletions

File tree

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "qryptchat-web",
33
"private": true,
4-
"version": "0.13.0",
4+
"version": "0.13.1",
55
"type": "module",
66
"bin": {
77
"qc": "./bin/qc.js",

‎packages/qryptchat/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@profullstack/qryptchat",
3-
"version": "0.9.0",
3+
"version": "0.9.1",
44
"description": "qc: qrypt.chat in your terminal. A full-screen end-to-end encrypted chat client (ML-KEM-1024), plus a scriptable CLI and an MCP server.",
55
"type": "module",
66
"bin": {

‎src/app/home-content.jsx‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,34 @@ export default function HomeContent() {
5151
</div>
5252
</div>
5353

54+
<section className="agents-voice" aria-labelledby="agents-voice-title">
55+
<div className="container">
56+
<div className="agents-voice-inner">
57+
<div className="agents-voice-copy">
58+
<span className="agents-voice-badge">🎙️ New</span>
59+
<h2 id="agents-voice-title">Voice chat with your AI agents</h2>
60+
<p className="agents-voice-lede">
61+
Invite your agents to a group, give them names, and just talk. They join the call, listen,
62+
take turns like people, and answer out loud in their own voices. Ask for real work and they
63+
get on it, then tell you how it went.
64+
</p>
65+
<ol className="agents-voice-steps">
66+
<li><strong>Invite your agents.</strong> Settings → AI agents sends an invite by link, email or text; an agent joins with <code>qc agent join</code> and makes its own keys.</li>
67+
<li><strong>Name them and add them to a group.</strong> One agent for code, one for your inbox, whatever you run: they each know their job.</li>
68+
<li><strong>Tap the mic.</strong> A voice call starts, your agents join, and you talk. Everything they say is also written into the chat.</li>
69+
</ol>
70+
<Link href="/auth" className="btn btn-primary agents-voice-cta">Start talking to your agents</Link>
71+
</div>
72+
<div className="agents-voice-call" aria-hidden="true">
73+
<div className="call-line you"><span>You</span>riotcoder, is the deploy green?</div>
74+
<div className="call-line agent"><span>🤖 riotcoder</span>Yep, all green. Want me to post the release notes?</div>
75+
<div className="call-line agent alt"><span>🤖 cha0spunk</span>And your inbox is clear, nothing waiting.</div>
76+
<div className="call-foot">🔒 End-to-end encrypted voice call</div>
77+
</div>
78+
</div>
79+
</div>
80+
</section>
81+
5482
<section className="features">
5583
<div className="container">
5684
<div className="section-header">
@@ -64,6 +92,7 @@ export default function HomeContent() {
6492
{ num: '03', title: '🔐 Encrypted Voice & Video Calls', desc: 'Crystal-clear 1:1 and group calls protected with ML-KEM-1024 post-quantum encryption.' },
6593
{ num: '04', title: 'Real-time Messaging', desc: 'Instant message delivery with typing indicators and read receipts.' },
6694
{ num: '05', title: 'Multi-language Support', desc: 'Available in multiple languages with full internationalization support.' },
95+
{ num: '06', title: '🤖 Voice Chat With Your AI Agents', desc: 'Invite your agents to a group, name them, and talk: they join an encrypted call and answer in their own voices.' },
6796
].map(({ num, title, desc }) => (
6897
<div key={num} className="feature-item">
6998
<div className="feature-number">{num}</div>
@@ -100,6 +129,25 @@ export default function HomeContent() {
100129
.steps li { color: var(--color-text-secondary); line-height: 1.7; font-size: 1.0625rem; }
101130
.steps li strong { color: var(--color-text-primary); }
102131
.audience { max-width: 760px; margin: var(--space-8) auto 0; text-align: center; color: var(--color-text-secondary); line-height: 1.7; }
132+
.agents-voice { padding: var(--space-20) 0; background: var(--color-bg-primary); }
133+
.agents-voice-inner { display: grid; grid-template-columns: 1.2fr 1fr; gap: var(--space-12); align-items: center; }
134+
.agents-voice-badge { display: inline-block; padding: var(--space-1) var(--space-3); border-radius: 999px; background: var(--color-bg-secondary); border: 1px solid var(--color-border-primary); font-size: .8125rem; font-weight: 600; color: var(--color-brand-primary); margin-bottom: var(--space-4); }
135+
.agents-voice h2 { font-size: 2.5rem; font-weight: 800; line-height: 1.15; color: var(--color-text-primary); margin-bottom: var(--space-4); }
136+
.agents-voice-lede { font-size: 1.1875rem; line-height: 1.7; color: var(--color-text-secondary); margin-bottom: var(--space-6); }
137+
.agents-voice-steps { padding-left: var(--space-6); display: flex; flex-direction: column; gap: var(--space-3); margin-bottom: var(--space-8); color: var(--color-text-secondary); line-height: 1.6; }
138+
.agents-voice-steps strong { color: var(--color-text-primary); }
139+
.agents-voice-steps code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; background: var(--color-bg-secondary); padding: 0 .3em; border-radius: 4px; }
140+
.agents-voice-cta { padding: var(--space-4) var(--space-8); font-size: 1.0625rem; font-weight: 600; }
141+
.agents-voice-call { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-6); border-radius: var(--radius-xl); background: linear-gradient(135deg, var(--color-brand-primary) 0%, var(--color-brand-secondary) 100%); box-shadow: var(--shadow-xl); }
142+
.call-line { max-width: 85%; padding: var(--space-3) var(--space-4); border-radius: 1rem; background: rgba(255,255,255,.95); color: #1a1a2e; line-height: 1.45; font-size: .9375rem; }
143+
.call-line span { display: block; font-size: .75rem; font-weight: 700; opacity: .65; margin-bottom: 2px; }
144+
.call-line.you { align-self: flex-end; background: rgba(0,0,0,.35); color: #fff; }
145+
.call-line.alt { background: rgba(255,255,255,.85); }
146+
.call-foot { color: rgba(255,255,255,.85); font-size: .8125rem; text-align: center; margin-top: var(--space-2); }
147+
@media (max-width: 768px) {
148+
.agents-voice-inner { grid-template-columns: 1fr; }
149+
.agents-voice h2 { font-size: 2rem; }
150+
}
103151
`}</style>
104152

105153
<style>{`
@@ -127,6 +175,8 @@ export default function HomeContent() {
127175
-webkit-text-fill-color: transparent;
128176
background-clip: text;
129177
}
178+
/* Grid items default to min-width:auto, so the nowrap install command stretched the page on phones. */
179+
.hero-text, .hero-visual, .agents-voice-copy, .agents-voice-call { min-width: 0; }
130180
.hero-tagline { font-size: 1.5rem; font-weight: 600; margin-bottom: var(--space-4); opacity: 0.9; }
131181
.hero-description { font-size: 1.125rem; line-height: 1.7; margin-bottom: var(--space-8); opacity: 0.8; }
132182
.hero-actions { display: flex; gap: var(--space-4); }

‎src/app/page.jsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const softwareApplicationJsonLd = {
3232
'Post-quantum end-to-end encryption (ML-KEM-1024 / CRYSTALS-Kyber, CRYSTALS-Dilithium)',
3333
'Phone-number authentication with no email required',
3434
'Encrypted 1:1 and group voice & video calls',
35+
'Voice chat with your AI agents: invite them to a group, name them, and talk',
3536
'Real-time messaging with typing indicators and read receipts',
3637
'Disappearing messages',
3738
'Encrypted file sharing',

‎src/cli/commands.js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Usage:
2323
qc open the chat client (signs you in first if needed)
2424
qc fonts install|status|remove our OpenEmoji colour font as the terminal's emoji font
2525
qc agent join <link> join as an AI agent from an invite (makes its own keys) [--name --username]
26-
qc agent call --brain "<cmd>" [--voice orion] [--post] [--no-greet]
26+
qc agent call --brain "<cmd>" [--voice orion] [--tts <url>] [--post] [--no-greet]
2727
as an agent, join voice calls in your chats: hear people, ask <cmd> what
2828
to say (JSON on stdin; it prints PASS or SAY: text), speak it
2929
(needs: npm i -g @livekit/rtc-node)
@@ -68,7 +68,7 @@ export function parseArgs(argv) {
6868
if (a.startsWith('--')) {
6969
const [k, v] = a.slice(2).split('=', 2);
7070
if (v !== undefined) args.flags[k] = v;
71-
else if (['url', 'n', 'limit', 'reply', 'emoji', 'pronouns', 'website', 'bio', 'name', 'username', 'brain', 'voice'].includes(k) && argv[i + 1] !== undefined && !argv[i + 1].startsWith('--')) args.flags[k] = argv[++i];
71+
else if (['url', 'n', 'limit', 'reply', 'emoji', 'pronouns', 'website', 'bio', 'name', 'username', 'brain', 'voice', 'tts'].includes(k) && argv[i + 1] !== undefined && !argv[i + 1].startsWith('--')) args.flags[k] = argv[++i];
7272
else args.flags[k] = true;
7373
} else if (a === '-n' && argv[i + 1] !== undefined) {
7474
args.flags.n = argv[++i];
@@ -141,6 +141,7 @@ export async function main(argv, { version = '0.0.0' } = {}) {
141141
return runVoiceAgent(await client(flags), {
142142
brain: typeof flags.brain === 'string' ? flags.brain : undefined,
143143
voice: typeof flags.voice === 'string' ? flags.voice : undefined,
144+
tts: typeof flags.tts === 'string' ? flags.tts : undefined,
144145
post: Boolean(flags.post),
145146
greet: !flags['no-greet'],
146147
hearAgents: Boolean(flags['hear-agents']),

‎src/cli/voice-agent.js‎

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
* The brain is any command (--brain "cmd"): it gets one JSON object on stdin
1515
* { agent, conversationId, title, speaker, speakerId, text, at, transcript: [{ who, text }] }
1616
* and prints PASS (say nothing) or SAY: <what to say>. It may post to the chat
17-
* itself; with --post the agent posts what it says as "🔊 …".
17+
* itself; with --post the agent posts what it says as "🔊 …". --tts <url> speaks with your
18+
* own voice server (POST { text, voice } -> 16-bit PCM WAV), falling back to qrypt.chat's.
1819
*
1920
* Needs @livekit/rtc-node (npm i -g @livekit/rtc-node), loaded only here.
2021
*/
@@ -119,8 +120,8 @@ export function askBrain(cmd, input, { timeoutMs = 90_000, env = process.env } =
119120

120121
/** One call the agent is in. */
121122
export class CallSession {
122-
constructor({ client, rtc, conversation, call, brain, voice, post, log, isHuman }) {
123-
Object.assign(this, { client, rtc, conversation, call, brain, voice, post, log, isHuman });
123+
constructor({ client, rtc, conversation, call, brain, voice, tts, post, log, isHuman }) {
124+
Object.assign(this, { client, rtc, conversation, call, brain, voice, ttsUrl: tts, post, log, isHuman });
124125
this.transcript = [];
125126
this.queue = Promise.resolve();
126127
this.speakToken = 0;
@@ -146,8 +147,9 @@ export class CallSession {
146147
await room.connect(url, token, { autoSubscribe: true, e2ee: e2eeOptions(this.call.key) });
147148
this.source = new AudioSource(SPEAK_RATE, 1);
148149
const track = LocalAudioTrack.createAudioTrack(`${this.client.me?.username || 'agent'}-voice`, this.source);
149-
const opts = new TrackPublishOptions();
150-
opts.source = TrackSource.SOURCE_MICROPHONE;
150+
// Speech, not music, but synthetic: a higher Opus bitrate and no DTX keep it from sounding
151+
// clipped and robotic; RED makes lost packets cheaper.
152+
const opts = new TrackPublishOptions({ source: TrackSource.SOURCE_MICROPHONE, dtx: false, red: true, audioEncoding: { maxBitrate: 64000n } });
151153
await room.localParticipant.publishTrack(track, opts);
152154
this.log(`joined the call in ${this.conversation.title}`);
153155
this.watchdog = setInterval(() => this.checkAlone(), 5000);
@@ -262,6 +264,20 @@ export class CallSession {
262264
}
263265

264266
async tts(sentence) {
267+
// Our own voice server first (--tts, e.g. a local Kokoro), then qrypt.chat's.
268+
if (this.ttsUrl) {
269+
try {
270+
const res = await this.client.fetch(this.ttsUrl, {
271+
method: 'POST',
272+
headers: { 'Content-Type': 'application/json' },
273+
body: JSON.stringify({ text: sentence, voice: this.voice }),
274+
});
275+
if (!res.ok) throw new Error(`HTTP ${res.status}`);
276+
return wavSamples(new Uint8Array(await res.arrayBuffer()));
277+
} catch (e) {
278+
this.log(`--tts failed (${e.message}); using qrypt.chat's voice`);
279+
}
280+
}
265281
const res = await this.client.fetch(`${this.client.base}/api/voice/speak`, {
266282
method: 'POST',
267283
headers: { Authorization: `Bearer ${await this.client.token()}`, 'Content-Type': 'application/json' },
@@ -315,7 +331,7 @@ async function latestCall(client, conversationId) {
315331
* Run the agent: join calls in its chats as they start, until stopped.
316332
* `rtc` and `onSession` are for tests.
317333
*/
318-
export async function runVoiceAgent(client, { brain, voice = 'orion', post = false, greet = true, hearAgents = false, log = (s) => process.stderr.write(`qc agent call: ${s}\n`), rtc, signal } = {}) {
334+
export async function runVoiceAgent(client, { brain, voice = 'orion', tts, post = false, greet = true, hearAgents = false, log = (s) => process.stderr.write(`qc agent call: ${s}\n`), rtc, signal } = {}) {
319335
if (!brain) throw new Error('Usage: qc agent call --brain "<command>" [--voice orion] [--post] [--no-greet]');
320336
rtc ??= await loadRtc();
321337
const sessions = new Map();
@@ -330,7 +346,7 @@ export async function runVoiceAgent(client, { brain, voice = 'orion', post = fal
330346

331347
const join = async (conversation, call) => {
332348
if (sessions.has(conversation.id) || Date.now() - Date.parse(call.at) > MAX_CALL_MS) return;
333-
const session = new CallSession({ client, rtc, conversation, call, brain, voice, post, log, isHuman });
349+
const session = new CallSession({ client, rtc, conversation, call, brain, voice, tts, post, log, isHuman });
334350
sessions.set(conversation.id, session);
335351
session.onClose = () => sessions.delete(conversation.id);
336352
try {

‎src/cli/voice-agent.test.js‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ describe('voice agent helpers', () => {
4242
});
4343

4444
describe('CallSession', () => {
45-
const make = (brain) => {
45+
const make = (brain, tts) => {
4646
const frames = [];
4747
const sent = [];
4848
const client = {
@@ -53,6 +53,7 @@ describe('CallSession', () => {
5353
fetch: vi.fn(async (url, init) => {
5454
if (url.endsWith('/api/voice/transcribe')) return { ok: true, json: async () => ({ text: 'is the deploy green?' }) };
5555
if (url.endsWith('/api/voice/speak')) return { ok: true, arrayBuffer: async () => encodeWav(new Float32Array(480).fill(0.1), 24000).buffer };
56+
if (url === 'http://kokoro/speak') return init.body.includes('broken') ? { ok: false, status: 500 } : { ok: true, arrayBuffer: async () => encodeWav(new Float32Array(240).fill(0.2), 24000).buffer };
5657
throw new Error(url);
5758
}),
5859
};
@@ -63,6 +64,7 @@ describe('CallSession', () => {
6364
conversation: { id: 'g1', title: 'Agents', participants: [{ user_id: 'h', user: { username: 'chovy' } }] },
6465
call: { key: new Uint8Array(32) },
6566
brain,
67+
tts,
6668
voice: 'orion',
6769
post: true,
6870
log: () => {},
@@ -85,6 +87,15 @@ describe('CallSession', () => {
8587
expect(s.transcript.map((t) => t.who)).toEqual(['chovy', 'riotcoder (you)']);
8688
});
8789

90+
it('speaks with its own voice server and falls back to qrypt.chat when it fails', async () => {
91+
const { s, client, frames } = make('echo PASS', 'http://kokoro/speak');
92+
await s.tts('fine').then((pcm) => expect(pcm.length).toBe(240));
93+
const pcm = await s.tts('broken');
94+
expect(pcm.length).toBe(480);
95+
expect(client.fetch.mock.calls.map(([u]) => u)).toEqual(['http://kokoro/speak', 'http://kokoro/speak', 'https://q/api/voice/speak']);
96+
expect(frames).toEqual([]);
97+
});
98+
8899
it('stays quiet on PASS and stops talking when interrupted', async () => {
89100
const { s, frames, sent } = make('echo PASS');
90101
await s.heard(new Float32Array(1600), 'chovy', 'h');

0 commit comments

Comments
 (0)