caelum0x d56639a594
Some checks failed
build-images / web (push) Has been cancelled
vision2026-ci / Python SDK resource tests (push) Has been cancelled
build-images / api (push) Has been cancelled
build-images / worker-gpu (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Has been cancelled
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Has been cancelled
codeql / Analyze (javascript-typescript) (push) Has been cancelled
codeql / Analyze (python) (push) Has been cancelled
perf / API hot-path micro-smoke (budgeted) (push) Has been cancelled
perf / Desktop engine crates (release build check) (push) Has been cancelled
vision2026-ci / API phase modules (ruff + pytest) (push) Has been cancelled
vision2026-ci / Alembic upgrade + drift check (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Has been cancelled
Menivor — open source release (MIT), free to use and fork
Paid, hosted product at menivor.com, now retired as a company project.
Fresh squashed history of the cleaned working tree (secret-scanned,
no .env, no customer data, no outreach logs). Built on
MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
2026-12-04 02:10:26 +03:00

51 lines
1.8 KiB
TypeScript

import type { UserVoice } from "@/lib/types";
/**
* Shared constants + helpers for the Brand Voice (voice cloning) surfaces.
* Kept framework-free so both the manager page and the wizard voice picker can
* import them without pulling in React.
*/
/** Narrator-selector prefix used by the backend (`voice_name` / `voice_id`). */
export const ELEVENLABS_PREFIX = "elevenlabs:";
/** Clone status the backend reports once a voice is usable. */
export const READY_STATUS = "ready";
/** Max accepted voice-sample size (bytes). Samples are short (30-60s). */
export const MAX_SAMPLE_BYTES = 25 * 1024 * 1024; // 25 MB
/** Recommended sample length window, surfaced as UI guidance. */
export const MIN_SAMPLE_SECONDS = 30;
export const MAX_SAMPLE_SECONDS = 60;
/**
* Strip the `"elevenlabs:"` prefix from a cloned voice's `voice_id`, yielding
* the bare provider voice id. The wizard stores the bare id and re-adds the
* prefix when building the job (`voice_name = "elevenlabs:<id>"`), so a cloned
* voice must be normalized the same way curated voices are to avoid a
* double-prefixed `elevenlabs:elevenlabs:<id>`.
*/
export function stripElevenLabsPrefix(voiceId: string): string {
return voiceId.startsWith(ELEVENLABS_PREFIX)
? voiceId.slice(ELEVENLABS_PREFIX.length)
: voiceId;
}
/** Whether a cloned voice has finished cloning and is selectable. */
export function isVoiceReady(voice: UserVoice): boolean {
return (voice.status || "").toLowerCase() === READY_STATUS;
}
/** Human-readable creation date, or `null` when unavailable/unparseable. */
export function formatCreatedAt(createdAt?: string | null): string | null {
if (!createdAt) return null;
const date = new Date(createdAt);
if (Number.isNaN(date.getTime())) return null;
return date.toLocaleDateString(undefined, {
year: "numeric",
month: "short",
day: "numeric",
});
}