Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: keep voice profile artifacts local (#5380)

[._.]/ Adam Eivy65f69fc4f099
diff --git a/client/src/components/universe/CharacterDetailEditor.jsx b/client/src/components/universe/CharacterDetailEditor.jsx
index f9261eb705..ed37ac2998 100644
--- a/client/src/components/universe/CharacterDetailEditor.jsx
+++ b/client/src/components/universe/CharacterDetailEditor.jsx
@@ -21,7 +21,12 @@ import useFieldDraft from '../../hooks/useFieldDraft';
import useRowDraft from '../../hooks/useRowDraft';
import usePendingListRows from '../../hooks/usePendingListRows';
import useAsyncAction from '../../hooks/useAsyncAction';
-import { listVoiceProfiles, promoteVoicePreset, renderVoiceProfileBenchmark } from '../../services/apiVoice';
+import {
+ listVoiceEngines,
+ listVoiceProfiles,
+ promoteVoicePreset,
+ renderVoiceProfileBenchmark,
+} from '../../services/apiVoice';
import VoicePicker from '../voice/VoicePicker';
import CollapsibleSection from '../ui/CollapsibleSection';
@@ -754,6 +759,7 @@ function VoiceProfileSection({ universeId, entry, disabled }) {
const [profile, setProfile] = useState(null);
const [loading, setLoading] = useState(Boolean(universeId));
const [loadError, setLoadError] = useState(null);
+ const [engineCapability, setEngineCapability] = useState(null);
const loadGeneration = useRef(0);
useEffect(() => {
let cancelled = false;
@@ -781,6 +787,21 @@ function VoiceProfileSection({ universeId, entry, disabled }) {
return () => { cancelled = true; };
}, [universeId, entry?.id]);
+ useEffect(() => {
+ if (!universeId) return undefined;
+ let cancelled = false;
+ listVoiceEngines({ silent: true })
+ .then((result) => {
+ if (cancelled) return;
+ const engine = entry?.voiceId?.split(':')[0];
+ setEngineCapability((result?.engines || []).find((item) => item.id === engine) || null);
+ })
+ .catch(() => {
+ if (!cancelled) setEngineCapability(null);
+ });
+ return () => { cancelled = true; };
+ }, [universeId, entry?.voiceId]);
+
const [promote, promoting] = useAsyncAction(async () => {
// A pending initial fetch must not erase the user action that just won.
loadGeneration.current += 1;
@@ -832,8 +853,28 @@ function VoiceProfileSection({ universeId, entry, disabled }) {
</button>
</div>
<p className="text-[10px] leading-snug text-gray-500">
- Kokoro and Piper support preset selection plus rate only. Pitch and formant controls are intentionally unavailable until a compatible local backend and formant-preserving transform are installed.
+ {engineCapability?.unavailableControls
+ || 'Kokoro and Piper support preset selection plus rate only. Pitch and formant controls are intentionally unavailable until a compatible local backend and formant-preserving transform are installed.'}
</p>
+ {profile?.benchmark?.lines?.length ? (
+ <div className="space-y-1.5">
+ <p className="text-[10px] text-gray-500">Fixed benchmark renders</p>
+ {profile.benchmark.lines.map((line, index) => (
+ <div key={line.filename} className="flex items-center gap-2">
+ <span className="w-4 shrink-0 text-[10px] text-gray-600">{index + 1}</span>
+ <audio
+ controls
+ preload="none"
+ src={`/data/${line.filename.split('/').map(encodeURIComponent).join('/')}`}
+ aria-label={`Voice benchmark ${line.key || index + 1}`}
+ className="h-7 min-w-0 flex-1"
+ >
+ <track kind="captions" />
+ </audio>
+ </div>
+ ))}
+ </div>
+ ) : null}
</BoxedSection>
);
}
diff --git a/client/src/components/universe/CharacterDetailEditor.test.jsx b/client/src/components/universe/CharacterDetailEditor.test.jsx
index ab168e7f38..bc66065cc4 100644
--- a/client/src/components/universe/CharacterDetailEditor.test.jsx
+++ b/client/src/components/universe/CharacterDetailEditor.test.jsx
@@ -6,12 +6,14 @@ import CharacterDetailEditor from './CharacterDetailEditor';
// tests don't care about.
vi.mock('../voice/VoicePicker', () => ({ default: () => null }));
vi.mock('../../services/apiVoice', () => ({
+ listVoiceEngines: vi.fn().mockResolvedValue({ engines: [] }),
listVoiceProfiles: vi.fn(),
promoteVoicePreset: vi.fn(),
renderVoiceProfileBenchmark: vi.fn(),
}));
import {
+ listVoiceEngines,
listVoiceProfiles,
promoteVoicePreset,
} from '../../services/apiVoice';
@@ -176,6 +178,7 @@ describe('CharacterDetailEditor — character framework (#2175)', () => {
describe('CharacterDetailEditor — production package (#5378)', () => {
it('keeps the empty local-profile state distinct and promotes a portable preset locally', async () => {
+ listVoiceEngines.mockResolvedValue({ engines: [] });
listVoiceProfiles.mockResolvedValue({ profiles: [] });
promoteVoicePreset.mockResolvedValueOnce({
profile: {
@@ -195,6 +198,24 @@ describe('CharacterDetailEditor — production package (#5378)', () => {
expect(await screen.findByRole('button', { name: /Re-promote selected preset/i })).toBeInTheDocument();
});
+ it('plays persisted local benchmark renders through the voice-profile asset mount', async () => {
+ listVoiceEngines.mockResolvedValue({ engines: [] });
+ listVoiceProfiles.mockResolvedValue({
+ profiles: [{
+ id: 'voice-profile-1', version: 1, voiceId: 'kokoro:af_heart', modelRevision: 'kokoro-test:q8',
+ delivery: { rate: 1 }, approval: { status: 'approved' },
+ benchmark: { lines: [{ key: 'identity', filename: 'voice-profiles/voice-profile-1/benchmarks/v1/01-identity.wav' }] },
+ }],
+ });
+ render(<CharacterDetailEditor
+ entry={{ ...ARIA, voiceId: 'kokoro:af_heart' }} universeId="uni-1" characters={[ARIA]} onPatch={() => {}}
+ />);
+ fireEvent.click(screen.getByRole('button', { name: /Local voice profile/i }));
+ expect(await screen.findByLabelText(/Voice benchmark identity/i)).toHaveAttribute(
+ 'src', '/data/voice-profiles/voice-profile-1/benchmarks/v1/01-identity.wav',
+ );
+ });
+
it('marks a voice-canon revision as approved', () => {
const onPatch = vi.fn();
render(<CharacterDetailEditor entry={ARIA} characters={[ARIA]} onPatch={onPatch} />);
diff --git a/client/src/services/apiVoice.js b/client/src/services/apiVoice.js
index 056a78a5fd..14a6326611 100644
--- a/client/src/services/apiVoice.js
+++ b/client/src/services/apiVoice.js
@@ -16,6 +16,7 @@ export const listVoiceProfiles = ({ universeId, characterId } = {}, options) =>
const query = params.toString();
return api.get(`/voice/profiles${query ? `?${query}` : ''}`, options);
};
+export const listVoiceEngines = (options) => api.get('/voice/engines', options);
export const promoteVoicePreset = (payload, options) => api.post('/voice/profiles/preset', payload, options);
export const renderVoiceProfileBenchmark = (profileId, options) => api.post(
`/voice/profiles/${encodeURIComponent(profileId)}/benchmark`, {}, options,
diff --git a/server/lib/assetRoutePrefixes.js b/server/lib/assetRoutePrefixes.js
index acc04ac1a6..5b8bccd25b 100644
--- a/server/lib/assetRoutePrefixes.js
+++ b/server/lib/assetRoutePrefixes.js
@@ -36,6 +36,7 @@ export const ASSET_ROUTE_PREFIXES = [
'/data/sprites',
'/data/image-to-3d',
'/data/audio',
+ '/data/voice-profiles',
'/data/music',
'/data/brain-imports',
'/data/writers-room/works',
diff --git a/server/routes/pipeline.test.js b/server/routes/pipeline.test.js
index 1487ee2fe0..b3d7c867b0 100644
--- a/server/routes/pipeline.test.js
+++ b/server/routes/pipeline.test.js
@@ -2735,6 +2735,26 @@ describe('pipeline routes', () => {
expect(issAfter.body.stages.audio.lines[0].audioFilename).toMatch(/^vo-mock-/);
});
+ it('keeps local voice profile provenance out of the federated issue record', async () => {
+ const audio = await import('../services/pipeline/audio.js');
+ audio.synthesizeToFile.mockResolvedValueOnce({
+ filename: 'vo-local-profile.wav', latencyMs: 5, engine: 'kokoro',
+ provenance: {
+ profileId: 'voice-profile-1', profileRevision: 2, engine: 'kokoro',
+ modelRevision: 'kokoro-test:q8', effectiveControls: { rate: 1 },
+ },
+ });
+ const app = makeApp();
+ const iss = await seedIssueWithStoryboards(app);
+ await request(app).post(`/api/pipeline/issues/${iss.id}/stages/audio/extract-lines`).send({});
+ const rendered = await request(app)
+ .post(`/api/pipeline/issues/${iss.id}/stages/audio/lines/0/render`)
+ .send({});
+ expect(rendered.status).toBe(200);
+ const reread = await request(app).get(`/api/pipeline/issues/${iss.id}`);
+ expect(reread.body.stages.audio.lines[0]).not.toHaveProperty('voiceProvenance');
+ });
+
it('POST /audio/lines/:idx/render 404s for out-of-range index', async () => {
const app = makeApp();
const iss = await seedIssueWithStoryboards(app);
diff --git a/server/routes/pipeline/audio.js b/server/routes/pipeline/audio.js
index b903ef258d..cd20f1bfa5 100644
--- a/server/routes/pipeline/audio.js
+++ b/server/routes/pipeline/audio.js
@@ -246,7 +246,6 @@ router.post('/issues/:id/stages/audio/lines/:lineIdx/render', asyncHandler(async
...line,
audioJobId: null,
audioFilename: synthResult.filename,
- ...(synthResult.provenance ? { voiceProvenance: synthResult.provenance } : {}),
};
const { issue: updatedIssue, stage } = await issuesSvc.updateStage(req.params.id, 'audio', {
status: 'edited',
diff --git a/server/services/assetMounts.js b/server/services/assetMounts.js
index 06c512edba..11b054ece3 100644
--- a/server/services/assetMounts.js
+++ b/server/services/assetMounts.js
@@ -60,6 +60,10 @@ const ASSET_DIRS = {
// Voice-over WAVs rendered by the pipeline audio stage — the AudioStage UI
// pulls them inline via <audio src="/data/audio/<filename>">.
'/data/audio': () => PATHS.audio,
+ // Machine-local voice-profile benchmarks and managed engine artifacts. The
+ // character editor exposes benchmark WAVs only; profile metadata remains
+ // behind its authenticated API.
+ '/data/voice-profiles': () => PATHS.voiceProfiles,
// Background-music tracks (uploaded today, generated locally tomorrow). The
// AudioStage music picker plays them inline via <audio src="/data/music/...">.
'/data/music': () => PATHS.music,
diff --git a/server/services/assetMounts.test.js b/server/services/assetMounts.test.js
index 7f87f25d2c..80a6a715e6 100644
--- a/server/services/assetMounts.test.js
+++ b/server/services/assetMounts.test.js
@@ -48,6 +48,9 @@ beforeAll(() => {
// bytes coming back rather than by the absence of a 404.
mkdirSync(join(tempRoot, 'images'), { recursive: true });
writeFileSync(join(tempRoot, 'images', 'probe.png'), 'PNGBYTES');
+ const voiceProfiles = join(tempRoot, 'voice-profiles', 'voice-profile-1', 'benchmarks', 'v1');
+ mkdirSync(voiceProfiles, { recursive: true });
+ writeFileSync(join(voiceProfiles, '01-identity.wav'), 'WAVBYTES');
const drafts = join(tempRoot, 'writers-room', 'works', 'wr-work-1');
mkdirSync(join(drafts, 'drafts'), { recursive: true });
writeFileSync(join(drafts, 'drafts', 'd1.md'), '# body');
@@ -121,6 +124,12 @@ describe('the server-owned namespace terminators', () => {
expect(res.status).toBe(200);
expect(res.text).toBe('PNGBYTES');
});
+
+ it('serves a local voice-profile benchmark from its dedicated mount', async () => {
+ const res = await request(app).get('/data/voice-profiles/voice-profile-1/benchmarks/v1/01-identity.wav');
+ expect(res.status).toBe(200);
+ expect(res.text).toBe('WAVBYTES');
+ });
});
describe('the writers-room draft-body gate', () => {
diff --git a/server/services/pipeline/issuesShared.js b/server/services/pipeline/issuesShared.js
index c81ddc00fd..30e7a632a3 100644
--- a/server/services/pipeline/issuesShared.js
+++ b/server/services/pipeline/issuesShared.js
@@ -462,36 +462,11 @@ export const sanitizeLineOffset = (raw) => {
return Math.min(n, AUDIO_LINE_OFFSET_MAX_SEC);
};
-// Render provenance is local production evidence, not a portable voice binding:
-// it records which approved local revision created a WAV without writing a
-// machine-local profile id back into the federated Universe character record.
-const sanitizeVoiceProvenance = (raw) => {
- if (!raw || typeof raw !== 'object') return null;
- const profileId = trimTo(raw.profileId, 80);
- const engine = trimTo(raw.engine, 32);
- if (!profileId || !engine) return null;
- return {
- profileId,
- profileRevision: Number.isInteger(raw.profileRevision) && raw.profileRevision > 0 ? raw.profileRevision : null,
- engine,
- modelRevision: trimTo(raw.modelRevision, 240) || null,
- effectiveControls: {
- rate: Number.isFinite(raw?.effectiveControls?.rate) ? raw.effectiveControls.rate : null,
- },
- mastering: {
- chain: Array.isArray(raw?.mastering?.chain)
- ? raw.mastering.chain.map((step) => trimTo(step, 80)).filter(Boolean).slice(0, 12)
- : [],
- },
- };
-};
-
const sanitizeAudioLine = (raw, i) => {
if (!raw || typeof raw !== 'object') return null;
const text = trimTo(raw.text, AUDIO_LINE_TEXT_MAX);
if (!text) return null;
const id = trimTo(raw.id, AUDIO_LINE_ID_MAX) || `line-${String(i + 1).padStart(3, '0')}`;
- const voiceProvenance = sanitizeVoiceProvenance(raw.voiceProvenance);
return {
id,
characterId: trimTo(raw.characterId, 80) || null,
@@ -505,7 +480,6 @@ const sanitizeAudioLine = (raw, i) => {
// Per-line start offset for muxing VO into the stitched episode (Phase
// 4d.2). null until the user (or a future auto-spacer) places it.
offsetSec: sanitizeLineOffset(raw.offsetSec),
- ...(voiceProvenance ? { voiceProvenance } : {}),
};
};
diff --git a/server/services/voice/profiles.js b/server/services/voice/profiles.js
index 6c8b6ac43c..8c3aa89cab 100644
--- a/server/services/voice/profiles.js
+++ b/server/services/voice/profiles.js
@@ -216,7 +216,7 @@ async function getBoundProfile(universeId, characterId) {
const { rows } = await query(
`SELECT data FROM voice_profiles
WHERE universe_id = $1 AND character_id = $2
- ORDER BY updated_at DESC, id DESC LIMIT 1`,
+ ORDER BY (approval_status = 'approved') DESC, updated_at DESC, id DESC LIMIT 1`,
[universeId, characterId],
);
return sanitizeVoiceProfile(rows[0]?.data);
diff --git a/server/services/voice/tts.js b/server/services/voice/tts.js
index 391f2b3892..a00f57d0e2 100644
--- a/server/services/voice/tts.js
+++ b/server/services/voice/tts.js
@@ -6,7 +6,7 @@ import { synthesizePiper, listPiperVoices } from './tts-piper.js';
import { findPiperVoice } from './piper-voices.js';
import { isKokoroVoice } from './kokoro-voices.js';
import { getProfileForSynthesis } from './profiles.js';
-import { which } from './bootstrap.js';
+import { whichFirst } from '../../lib/processEnv.js';
import { ServerError } from '../../lib/errorHandler.js';
// Single source of truth for the supported TTS engine names. Imported by
@@ -23,7 +23,7 @@ let voiceTransformProbe = null;
const probeVoiceTransforms = () => {
if (!voiceTransformProbe) {
- voiceTransformProbe = which('rubberband').then((rubberband) => ({
+ voiceTransformProbe = whichFirst('rubberband').then((rubberband) => ({
rubberband: Boolean(rubberband),
}));
}