Integração: vídeo final ao aprovar + dublagem em português
Conflito em editor_api.render_clip_edit (as duas frentes mexeram na chamada de render): passa a tradução, `dev` e o dublador juntos. review_layers: a dublagem sai das frases traduzidas, então sem frase (fonte em português) não houve dublagem e o vídeo de revisão já é o final. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -242,7 +242,15 @@ export type CutSettings = {
|
||||
translation?: boolean;
|
||||
};
|
||||
/** Camadas só de desenvolvimento (vídeo de revisão); o vídeo final, depois de aprovar, sai sem elas. */
|
||||
dev?: { translation: boolean; dub: boolean };
|
||||
dev?: {
|
||||
translation: boolean; dub: boolean;
|
||||
/** Dublagem (doc/clipador/DUBLAGEM.md): voz TTS pronta do serviço de voz — nunca clone do streamer. */
|
||||
dubVoice?: string;
|
||||
/** Voz das falas marcadas como de outra pessoa (`speaker: "other"`). */
|
||||
dubVoiceOther?: string;
|
||||
/** Volume do áudio original enquanto a dublagem toca (0–1). */
|
||||
dubDuck?: number;
|
||||
};
|
||||
credit: { enabled: boolean; position: "top" | "bottom"; size: number };
|
||||
duration: { minS: number; maxS: number; backtrackS: number };
|
||||
/** O serviço antigo não manda este grupo: use `withFormat` para preencher com vertical. */
|
||||
|
||||
@@ -18,7 +18,8 @@ import {
|
||||
} from "./icons";
|
||||
import { RECT_MIN_SIZE, clampRect, moveRect, nudgeRect, resizeRect } from "./rect-geometry";
|
||||
import { Tabs, type TabItem } from "./tabs";
|
||||
import { Badge, Button, ChoiceGroup, Feedback, RangeField, Spinner, Switch, cx, fileUrl } from "./ui";
|
||||
import { Badge, Button, ChoiceGroup, Feedback, Field, RangeField, Select, Spinner, Switch, cx, fileUrl } from "./ui";
|
||||
import type { VoiceInfo } from "./voice-client";
|
||||
// Gancho e fontes (editor de cortes): seletor com amostra e fontes empacotadas carregadas no navegador.
|
||||
import { HOOK_ANIM_LABEL, HOOK_STYLE_LABEL, SYSTEM_FONTS, hookOf, type HookAnim, type HookSettings, type HookStyle } from "./clipper-client";
|
||||
import { FontPicker, fontStack, usePackagedFonts } from "./clip-editor-fonts";
|
||||
@@ -523,6 +524,7 @@ function CutSettingsEditor({ scope, onDirty, onClose, onSaved }: {
|
||||
<MockFigure aspect={aspect} layout={draft.layout} caption={draft.caption} credit={null} />
|
||||
</div>
|
||||
</fieldset>
|
||||
<DubSettings dev={draft.dev} onChange={(values) => update("dev", values)} />
|
||||
</Section>
|
||||
);
|
||||
|
||||
@@ -708,6 +710,68 @@ function CutSettingsEditor({ scope, onDirty, onClose, onSaved }: {
|
||||
);
|
||||
}
|
||||
|
||||
/* ----- Dublagem em português (camada de teste; doc/clipador/DUBLAGEM.md) ----- */
|
||||
|
||||
// Padrões do Clipador (layout.DEFAULTS["dev"]); valem com o serviço antigo, que ainda não manda as chaves.
|
||||
const DUB_VOICE = "pt-br-antonio";
|
||||
const DUB_VOICE_OTHER = "kokoro-pm-alex";
|
||||
const DUB_DUCK = 0.25;
|
||||
|
||||
function voiceLabel(v: VoiceInfo): string {
|
||||
const gender = v.gender === "male" ? "masculina" : v.gender === "female" ? "feminina" : null;
|
||||
return [v.name, gender, v.offline ? "offline" : "online"].filter(Boolean).join(" · ");
|
||||
}
|
||||
|
||||
/** Fica fora da caixa da legenda: a dublagem não depende de a legenda estar ligada. */
|
||||
function DubSettings({ dev, onChange }: {
|
||||
dev: CutSettings["dev"]; onChange: (values: Partial<NonNullable<CutSettings["dev"]>>) => void;
|
||||
}) {
|
||||
const on = dev?.dub ?? false;
|
||||
const [voices, setVoices] = useState<VoiceInfo[] | null>(null);
|
||||
useEffect(() => {
|
||||
if (!on || voices) return;
|
||||
let alive = true;
|
||||
// Só vozes TTS prontas em português: voz clonada fica de fora (nunca imitar o streamer, que não consentiu).
|
||||
fetch("/api/voice/status", { cache: "no-store" }).then((r) => r.json()).then((s: { voices?: VoiceInfo[] }) => {
|
||||
if (alive) setVoices((s.voices ?? []).filter((v) => v.provider !== "clone" && (v.languages ?? []).some((l) => l.toLowerCase().startsWith("pt"))));
|
||||
}).catch(() => { if (alive) setVoices([]); });
|
||||
return () => { alive = false; };
|
||||
}, [on, voices]);
|
||||
const voice = dev?.dubVoice ?? DUB_VOICE;
|
||||
const other = dev?.dubVoiceOther ?? DUB_VOICE_OTHER;
|
||||
const duck = dev?.dubDuck ?? DUB_DUCK;
|
||||
const options = (current: string) => {
|
||||
const list = voices ?? [];
|
||||
// A voz salva aparece mesmo se o serviço estiver fora (ou se ela sair do catálogo).
|
||||
return list.some((v) => v.id === current) ? list : [{ id: current, name: current } as VoiceInfo, ...list];
|
||||
};
|
||||
return (
|
||||
<div className="mt-6 grid gap-x-8 gap-y-4 border-t border-line pt-5 xl:grid-cols-2">
|
||||
<Switch label="Dublagem em português (teste)" checked={on} onChange={(dub) => onChange({ dub })}
|
||||
hint={"Só no vídeo de revisão (fonte em inglês): cada frase traduzida é dublada por uma voz TTS pronta e o áudio original fica baixo por baixo — dá para ouvir o jogo. O 1º render demora mais (~1,6 s por frase; depois fica guardado). O vídeo final, ao aprovar, sai com o áudio original."} />
|
||||
{on && (
|
||||
<div className="grid content-start gap-4">
|
||||
{voices === null && <p role="status" className="flex items-center gap-2 text-xs text-fg-subtle"><Spinner className="size-3" />Carregando as vozes…</p>}
|
||||
{voices !== null && voices.length === 0 && <Note tone="warning">Serviço de voz fora do ar: a dublagem não sai até ele voltar.</Note>}
|
||||
<Field label="Voz do streamer">
|
||||
<Select value={voice} onChange={(e) => onChange({ dubVoice: e.target.value })}>
|
||||
{options(voice).map((v) => <option key={v.id} value={v.id}>{v.languages ? voiceLabel(v) : v.id}</option>)}
|
||||
</Select>
|
||||
</Field>
|
||||
<Field label="Voz de outra pessoa" hint="Para as falas de quem não é o streamer, quando a transcrição separar quem fala.">
|
||||
<Select value={other} onChange={(e) => onChange({ dubVoiceOther: e.target.value })}>
|
||||
{options(other).map((v) => <option key={v.id} value={v.id}>{v.languages ? voiceLabel(v) : v.id}</option>)}
|
||||
</Select>
|
||||
</Field>
|
||||
<RangeField label="Volume do áudio original durante a dublagem" min={0} max={1} step={0.05} value={duck}
|
||||
onChange={(dubDuck) => onChange({ dubDuck })} format={pct}
|
||||
hint="Fora das falas dubladas o áudio fica normal." />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function countFields(layer: CutLayer | null | undefined): number {
|
||||
return Object.values(layer ?? {}).reduce((n, g) => n + Object.keys(g ?? {}).length, 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user