- app/ (Electron 45 + TypeScript): the core joins one voice channel, decodes each speaker's Opus to 48 kHz stereo and streams it to the voice worker, sends speaking_end and speaker_leave, and emits speech_start/partial/final with the speaker's display name. - Sentence playback from the worker's TTS, first come first served, with stop that silences the clip at once and cancels unfinished requests; slash command join/leave/stop (create-or-update by name). - Transcription notice posted on every join; other bots ignored by default; at most maxSpeakers people transcribed at once. - Registered chat channels: live message events, history reads, sends split at 2,000 characters with mentions disabled; Message Content intent checked before login. - The app starts the Python voice worker with a fresh token in the environment, restarts it with backoff, and the worker client reconnects and fails in-flight TTS on a lost connection. - Spec in app/src/core/discord_core.spec.md; Vitest unit tests, a protocol test against the real Python worker server with fake engines, and an opt-in live test with two bots on real Discord. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
25 lines
829 B
TypeScript
25 lines
829 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { SpeakerGate } from "../src/core/speakers.js";
|
|
|
|
describe("SpeakerGate", () => {
|
|
it("hears up to the limit and lets the next person in once someone stops", () => {
|
|
const g = new SpeakerGate(2);
|
|
expect(g.start("a")).toBe(true);
|
|
expect(g.start("b")).toBe(true);
|
|
expect(g.start("c")).toBe(false);
|
|
expect(g.isActive("c")).toBe(false);
|
|
expect(g.end("a")).toBe(true);
|
|
expect(g.start("c")).toBe(true);
|
|
expect(g.count).toBe(2);
|
|
});
|
|
|
|
it("a speaker already heard stays heard; ending someone not heard is a no-op", () => {
|
|
const g = new SpeakerGate(1);
|
|
expect(g.start("a")).toBe(true);
|
|
expect(g.start("a")).toBe(true);
|
|
expect(g.end("z")).toBe(false);
|
|
expect(g.end("a")).toBe(true);
|
|
expect(g.end("a")).toBe(false);
|
|
});
|
|
});
|