Skip to content

Open source CapCut alternative.

TypeScript

feat(site): fill Cut audio preview with the full spoken line

David Le2933eefe7eb9
diff --git a/site/src/cut/components/AudioPanel.tsx b/site/src/cut/components/AudioPanel.tsx
index ed852d57..ef9d31e4 100644
--- a/site/src/cut/components/AudioPanel.tsx
+++ b/site/src/cut/components/AudioPanel.tsx
@@ -144,7 +144,10 @@ function VoiceGenerator({ projectId }: { projectId: string }) {
setError(null);
try {
const playhead = useEditor.getState().currentTime;
- const lead = text.split(/\s+/).slice(0, 4).join(" ");
+ // Label with the spoken line, not just its first words, so the preview
+ // fills across the row (each surface truncates to its own width). Collapse
+ // whitespace and cap it so project.json stays lean.
+ const lead = text.replace(/\s+/g, " ").trim().slice(0, 200);
// synthesizeSpeech reads the direction for a "say it in X" ask and
// translates the script into that language before speaking it.
const { asset } = await synthesizeSpeech(projectId, [{ text, at: 0 }], {
diff --git a/site/src/cut/lib/aiTools.ts b/site/src/cut/lib/aiTools.ts
index 0cb12310..a709f0e1 100644
--- a/site/src/cut/lib/aiTools.ts
+++ b/site/src/cut/lib/aiTools.ts
@@ -1027,7 +1027,8 @@ export async function runAiTool(
if (typeof input.script !== "string" || !input.script.trim())
throw new ToolError("script is required.");
const start = isNum(input.start) ? Math.max(0, input.start) : s.currentTime;
- const lead = input.script.trim().split(/\s+/).slice(0, 4).join(" ");
+ // Label with the spoken line (capped) so its preview fills across the row.
+ const lead = input.script.replace(/\s+/g, " ").trim().slice(0, 200);
const place = wantsTimeline(input, "start");
return synthesizeVoiceover(
[{ text: input.script, at: 0 }],