github-actions[bot] commited on
Commit
eb9318e
·
1 Parent(s): bee14d9

Automated Deploy: 69002f0c801b41c0be09f5e671f1f8912f99125d

Browse files
backend/app/assets/asset_controller.py CHANGED
@@ -63,7 +63,10 @@ def download(asset_id: str, db: Session = Depends(get_session)):
63
  )
64
  if job:
65
  storage.get(job.settings["scene"]["image_asset_id"], "image")
66
- if job.settings["kind"] == "animated":
 
 
 
67
  for character in job.settings["characters"]:
68
  storage.get(character["voice_asset_id"], "voice")
69
  path = storage.path(asset)
 
63
  )
64
  if job:
65
  storage.get(job.settings["scene"]["image_asset_id"], "image")
66
+ if (
67
+ job.settings["kind"] == "animated"
68
+ and job.settings["providers"]["speech"] == "chatterbox"
69
+ ):
70
  for character in job.settings["characters"]:
71
  storage.get(character["voice_asset_id"], "voice")
72
  path = storage.path(asset)
backend/app/generations/generation_schema.py CHANGED
@@ -6,8 +6,8 @@ from pydantic import BaseModel, ConfigDict, Field
6
  class GenerationCreate(BaseModel):
7
  conversation_id: str
8
  scene_id: str
9
- kind: Literal["storyboard", "animated"] = "storyboard"
10
- target_seconds: int = Field(default=60, ge=10, le=65)
11
 
12
 
13
  class GenerationRead(BaseModel):
 
6
  class GenerationCreate(BaseModel):
7
  conversation_id: str
8
  scene_id: str
9
+ kind: Literal["storyboard", "animated"] = "animated"
10
+ target_seconds: int = Field(default=60, ge=1, le=60)
11
 
12
 
13
  class GenerationRead(BaseModel):
backend/app/generations/generation_worker.py CHANGED
@@ -66,8 +66,15 @@ def run_generation(job_id: str):
66
  output = folder / "conversation.mp4"
67
  if snapshot["kind"] == "storyboard":
68
  progress("Rendering silent storyboard", 40)
69
- VideoService().storyboard(image, output, snapshot["target_seconds"])
70
- duration = snapshot["target_seconds"]
 
 
 
 
 
 
 
71
  else:
72
  providers = snapshot["providers"]
73
  if (
 
66
  output = folder / "conversation.mp4"
67
  if snapshot["kind"] == "storyboard":
68
  progress("Rendering silent storyboard", 40)
69
+ # A storyboard has no measured speech; use a reading-time estimate.
70
+ turns = snapshot["conversation"]["turns"]
71
+ duration = min(
72
+ 60,
73
+ snapshot["target_seconds"],
74
+ max(1, sum(len(t["text"].split()) / 2.3 for t in turns)
75
+ + sum(t["pause_after"] for t in turns[:-1])),
76
+ )
77
+ VideoService().storyboard(image, output, duration)
78
  else:
79
  providers = snapshot["providers"]
80
  if (
backend/app/shared/audio_service.py CHANGED
@@ -61,13 +61,15 @@ class AudioService:
61
  tracks = {i: array("h") for i in character_ids}
62
  timeline = []
63
  cursor = 0
64
- for turn, clip in zip(turns, clips, strict=True):
65
  samples = wav_read(clip)
66
  length = len(samples)
 
 
67
  timeline.append(
68
  {**turn, "start": cursor / RATE, "end": (cursor + length) / RATE}
69
  )
70
- gap = int(turn["pause_after"] * RATE)
71
  for identity in character_ids:
72
  tracks[identity].extend(
73
  samples
@@ -77,11 +79,13 @@ class AudioService:
77
  tracks[identity].extend(array("h", [0]) * gap)
78
  cursor += length + gap
79
  actual = cursor / RATE
80
- if abs(actual - target_seconds) > 5:
 
81
  raise ValueError(
82
- f"Speech is {actual:.1f}s; target is {target_seconds}s ±5s. Edit dialogue or pace and render again. Words were not changed."
 
83
  )
84
- length = max(cursor, target_seconds * RATE)
85
  paths = []
86
  for index, identity in enumerate(character_ids):
87
  tracks[identity].extend(array("h", [0]) * (length - cursor))
 
61
  tracks = {i: array("h") for i in character_ids}
62
  timeline = []
63
  cursor = 0
64
+ for index, (turn, clip) in enumerate(zip(turns, clips, strict=True)):
65
  samples = wav_read(clip)
66
  length = len(samples)
67
+ if not samples or not any(samples):
68
+ raise ValueError("Speech provider returned empty or silent audio. Render again.")
69
  timeline.append(
70
  {**turn, "start": cursor / RATE, "end": (cursor + length) / RATE}
71
  )
72
+ gap = int(turn["pause_after"] * RATE) if index < len(turns) - 1 else 0
73
  for identity in character_ids:
74
  tracks[identity].extend(
75
  samples
 
79
  tracks[identity].extend(array("h", [0]) * gap)
80
  cursor += length + gap
81
  actual = cursor / RATE
82
+ limit = min(target_seconds, 60)
83
+ if actual > limit:
84
  raise ValueError(
85
+ f"Speech is {actual:.1f}s; the maximum is {limit}s. "
86
+ "Shorten the dialogue or increase pace and render again. Words were not changed."
87
  )
88
+ length = cursor
89
  paths = []
90
  for index, identity in enumerate(character_ids):
91
  tracks[identity].extend(array("h", [0]) * (length - cursor))
backend/model_services/lightweight_service.py CHANGED
@@ -16,6 +16,7 @@ from fastapi.responses import Response
16
 
17
  app = FastAPI(title="Kokoro and SadTalker")
18
  lock = threading.Lock()
 
19
  VOICES = {"af_heart", "af_bella"}
20
 
21
 
@@ -83,7 +84,7 @@ def health(authorization: str = Header(default="")):
83
  ]
84
  if not all(p.is_file() for p in required):
85
  raise HTTPException(503, "Install SadTalker environment and checkpoints")
86
- with lock:
87
  check_runtime()
88
  return {"status": "ok", "model": "kokoro+sadtalker", "inference_verified": False}
89
 
@@ -155,9 +156,9 @@ def generate(
155
  save_upload(upload, path)
156
  lengths = [wav_duration(path) for path in tracks]
157
  duration = lengths[0]
158
- if not 1 <= duration <= 65 or abs(duration - lengths[1]) > 0.04:
159
  raise HTTPException(
160
- 422, "Supply two aligned tracks of equal length, up to 65 seconds"
161
  )
162
  portraits = []
163
  for side in range(2):
 
16
 
17
  app = FastAPI(title="Kokoro and SadTalker")
18
  lock = threading.Lock()
19
+ runtime_lock = threading.Lock()
20
  VOICES = {"af_heart", "af_bella"}
21
 
22
 
 
84
  ]
85
  if not all(p.is_file() for p in required):
86
  raise HTTPException(503, "Install SadTalker environment and checkpoints")
87
+ with runtime_lock:
88
  check_runtime()
89
  return {"status": "ok", "model": "kokoro+sadtalker", "inference_verified": False}
90
 
 
156
  save_upload(upload, path)
157
  lengths = [wav_duration(path) for path in tracks]
158
  duration = lengths[0]
159
+ if not 0 < duration <= 60 or abs(duration - lengths[1]) > 0.04:
160
  raise HTTPException(
161
+ 422, "Supply two aligned tracks of equal length, up to 60 seconds"
162
  )
163
  portraits = []
164
  for side in range(2):
backend/tests/conftest.py CHANGED
@@ -6,6 +6,8 @@ _storage = TemporaryDirectory()
6
  os.environ["DATABASE_URL"] = "sqlite:///" + str(Path(_storage.name) / "test.db")
7
  os.environ["ASSETS_DIR"] = str(Path(_storage.name) / "assets")
8
  os.environ["SEED_CHARACTERS"] = "true"
 
 
9
  os.environ["SPEECH_URL"] = ""
10
  os.environ["VIDEO_URL"] = ""
11
 
 
6
  os.environ["DATABASE_URL"] = "sqlite:///" + str(Path(_storage.name) / "test.db")
7
  os.environ["ASSETS_DIR"] = str(Path(_storage.name) / "assets")
8
  os.environ["SEED_CHARACTERS"] = "true"
9
+ os.environ["FIXED_DEMO_MODE"] = "false"
10
+ os.environ["ENABLE_ANIMATED_RENDERS"] = "false"
11
  os.environ["SPEECH_URL"] = ""
12
  os.environ["VIDEO_URL"] = ""
13
 
backend/tests/test_workflow.py CHANGED
@@ -131,6 +131,7 @@ def test_real_storyboard_render(client):
131
  "conversation_id": script["id"],
132
  "scene_id": scene["id"],
133
  "target_seconds": 10,
 
134
  },
135
  )
136
  assert response.status_code == 201
@@ -140,7 +141,7 @@ def test_real_storyboard_render(client):
140
  run_generation(job_id)
141
  job = client.get(f"/api/v1/generations/{job_id}").json()
142
  assert job["status"] == "completed", job
143
- assert job["duration"] == 10
144
  video = client.get(f"/api/v1/assets/{job['output_asset_id']}/file")
145
  assert video.status_code == 200 and b"ftyp" in video.content[:64]
146
  assert (
@@ -174,7 +175,7 @@ def test_gpu_not_faked_and_revocation(client):
174
  assert (
175
  client.post(
176
  "/api/v1/generations",
177
- json={"conversation_id": script["id"], "scene_id": scene["id"]},
178
  ).status_code
179
  == 404
180
  )
@@ -193,9 +194,93 @@ def test_audio_alignment_and_duration(tmp_path):
193
  paths, timeline, duration = AudioService().align(
194
  turns, clips, ["a", "b"], tmp_path, 10
195
  )
196
- assert duration == 10 and timeline[1]["start"] == 5 and len(paths) == 2
197
  from app.shared.audio_service import wav_read
198
 
199
  assert max(wav_read(paths[1])[: RATE * 5]) == 0
 
 
200
  with pytest.raises(ValueError, match="Words were not changed"):
201
- AudioService().align(turns, clips, ["a", "b"], tmp_path, 60)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
  "conversation_id": script["id"],
132
  "scene_id": scene["id"],
133
  "target_seconds": 10,
134
+ "kind": "storyboard",
135
  },
136
  )
137
  assert response.status_code == 201
 
141
  run_generation(job_id)
142
  job = client.get(f"/api/v1/generations/{job_id}").json()
143
  assert job["status"] == "completed", job
144
+ assert 0 < job["duration"] < 10
145
  video = client.get(f"/api/v1/assets/{job['output_asset_id']}/file")
146
  assert video.status_code == 200 and b"ftyp" in video.content[:64]
147
  assert (
 
175
  assert (
176
  client.post(
177
  "/api/v1/generations",
178
+ json={"conversation_id": script["id"], "scene_id": scene["id"], "kind": "storyboard"},
179
  ).status_code
180
  == 404
181
  )
 
194
  paths, timeline, duration = AudioService().align(
195
  turns, clips, ["a", "b"], tmp_path, 10
196
  )
197
+ assert duration == 9 and timeline[1]["start"] == 5 and len(paths) == 2
198
  from app.shared.audio_service import wav_read
199
 
200
  assert max(wav_read(paths[1])[: RATE * 5]) == 0
201
+ _, _, duration = AudioService().align(turns, clips, ["a", "b"], tmp_path, 60)
202
+ assert duration == 9
203
  with pytest.raises(ValueError, match="Words were not changed"):
204
+ AudioService().align(turns, clips, ["a", "b"], tmp_path, 8)
205
+
206
+
207
+ def test_generation_defaults_and_maximum(client):
208
+ from app.generations.generation_schema import GenerationCreate
209
+ from pydantic import ValidationError
210
+
211
+ assert GenerationCreate(conversation_id="c", scene_id="s").kind == "animated"
212
+ for seconds in (0, 61, 65):
213
+ with pytest.raises(ValidationError):
214
+ GenerationCreate(conversation_id="c", scene_id="s", target_seconds=seconds)
215
+
216
+
217
+ def test_audio_limit_and_silent_provider(tmp_path):
218
+ from app.shared.audio_service import wav_read
219
+
220
+ clip = tmp_path / "voice.wav"
221
+ turns = [{"character_id": "a", "text": "hello", "pause_after": 5}]
222
+ wav_write(clip, array("h", [1000]) * RATE * 60)
223
+ paths, _, duration = AudioService().align(turns, [clip], ["a", "b"], tmp_path, 60)
224
+ assert duration == 60
225
+ assert len(wav_read(paths[0])) == RATE * 60
226
+ wav_write(clip, array("h", [1000]) * (RATE * 60 + 1))
227
+ with pytest.raises(ValueError, match="maximum is 60s"):
228
+ AudioService().align(turns, [clip], ["a", "b"], tmp_path, 65)
229
+ wav_write(clip, array("h", [0]) * RATE)
230
+ with pytest.raises(ValueError, match="silent audio"):
231
+ AudioService().align(turns, [clip], ["a", "b"], tmp_path, 60)
232
+
233
+
234
+ def test_animated_worker_exports_short_video_with_audio(client, monkeypatch, tmp_path):
235
+ """Stub model inference only; exercise real alignment, muxing and publication."""
236
+ import math
237
+ import subprocess
238
+ import imageio_ffmpeg
239
+ from app.config import settings
240
+ from app.generations import generation_worker, generation_service
241
+ from app.shared.audio_service import wav_read
242
+
243
+ monkeypatch.setattr(settings, "enable_animated_renders", True)
244
+ monkeypatch.setattr(settings, "speech_provider", "kokoro")
245
+ monkeypatch.setattr(settings, "video_provider", "sadtalker")
246
+ monkeypatch.setattr(settings, "speech_url", "http://test-model")
247
+ monkeypatch.setattr(settings, "video_url", "http://test-model")
248
+ monkeypatch.setattr(generation_service, "lightweight_ready", lambda: True)
249
+
250
+ class Speech:
251
+ def synthesize(self, text, voice, output, profile):
252
+ wav_write(output, array("h", (int(4000 * math.sin(2 * math.pi * 440 * i / RATE)) for i in range(RATE))))
253
+ return output
254
+
255
+ class Video:
256
+ def generate(self, image, tracks, output, prompt):
257
+ duration = len(wav_read(tracks[0])) / RATE
258
+ assert duration == pytest.approx(2.4)
259
+ assert len(wav_read(tracks[1])) == len(wav_read(tracks[0]))
260
+ subprocess.run([imageio_ffmpeg.get_ffmpeg_exe(), "-y", "-f", "lavfi", "-i",
261
+ "testsrc2=size=128x128:rate=25", "-t", str(duration),
262
+ "-c:v", "libx264", str(output)], check=True, capture_output=True)
263
+ return output
264
+
265
+ monkeypatch.setattr(generation_worker, "speech_provider", lambda _: Speech())
266
+ monkeypatch.setattr(generation_worker, "video_provider", lambda _: Video())
267
+ script, scene = setup_project(client)
268
+ response = client.post("/api/v1/generations", json={"conversation_id": script["id"], "scene_id": scene["id"]})
269
+ assert response.status_code == 201, response.text
270
+ job_id = response.json()["id"]
271
+ assert claim_job() == job_id
272
+ run_generation(job_id)
273
+ job = client.get(f"/api/v1/generations/{job_id}").json()
274
+ assert job["status"] == "completed", job
275
+ assert job["duration"] == pytest.approx(2.4)
276
+ output = tmp_path / "output.mp4"
277
+ download = client.get(f"/api/v1/assets/{job['output_asset_id']}/file")
278
+ assert download.status_code == 200, download.text
279
+ output.write_bytes(download.content)
280
+ decoded = tmp_path / "decoded.wav"
281
+ AudioService().normalize(output, decoded)
282
+ samples = wav_read(decoded)
283
+ assert max(samples) > 1000
284
+ assert len(samples) / RATE == pytest.approx(2.4, abs=0.1)
285
+ result = subprocess.run([imageio_ffmpeg.get_ffmpeg_exe(), "-i", str(output), "-map", "0:v:0", "-f", "null", "-"], capture_output=True)
286
+ assert result.returncode == 0
frontend/dist/assets/{index-DIHfNPvU.js → index-Bfi-8Lau.js} RENAMED
The diff for this file is too large to render. See raw diff
 
frontend/e2e/studio.spec.ts CHANGED
@@ -1,50 +1,20 @@
1
  import { test, expect } from '@playwright/test';
2
 
3
- // These tests use the actual API, SQLite and FFmpeg worker. No network interception.
4
- // The fixture is a synthetic solid image, not a model-quality test.
5
- const image = Buffer.from(
6
- 'iVBORw0KGgoAAAANSUhEUgAAAoAAAAFoCAIAAABIUN0GAAAFl0lEQVR4nO3XMRHAMBDEQDv8iQRBKBhWWLwK7xK4UnP7e88CAGY9w3sAgAADQMMDBoCAAANAQIABICDAABAQYAAICDAABAQYAAICDAABAQaAgAADQECAASAgwAAQEGAACAgwAAQEGAACAgwAAQEGgIAAA0BAgAEgIMAAEBBgAAgIMAAEBBgAAgIMAAEBBoCAAANAQIABICDAABAQYAAICDAABAQYAAICDAABAQaAgAADQECAASAgwAAQEGAACAgwAAQEGAACAgwAAQEGgIAAA0BAgAEgIMAAEBBgAAgIMAAEBBgAAgIMAAEBBoCAAANAQIABICDAABAQYAAICDAABAQYAAICDAABAQaAgAADQECAASAgwAAQEGAACAgwAAQEGAACAgwAAQEGgIAAA0BAgAEgIMAAEBBgAAgIMAAEBBgAAgIMAAEBBoCAAANAQIABICDAABAQYAAICDAABAQYAAICDAABAQaAgAADQECAASAgwAAQEGAACAgwAAQEGAACAgwAAQEGgIAAA0BAgAEgIMAAEBBgAAgIMAAEBBgAAgIMAAEBBoCAAANAQIABICDAABAQYAAICDAABAQYAAICDAABAQaAgAADQECAASAgwAAQEGAACAgwAAQEGAACAgwAAQEGgIAAA0BAgAEgIMAAEBBgAAgIMAAEBBgAAgIMAAEBBoCAAANAQIABICDAABAQYAAICDAABAQYAAICDAABAQaAgAADQECAASAgwAAQEGAACAgwAAQEGAACAgwAAQEGgIAAA0BAgAEgIMAAEBBgAAgIMAAEBBgAAgIMAAEBBoCAAANAQIABICDAABAQYAAICDAABAQYAAICDAABAQaAgAADQECAASAgwAAQEGAACAgwAAQEGAACAgwAAQEGgIAAA0BAgAEgIMAAEBBgAAgIMAAEBBgAAgIMAAEBBoCAAANAQIABICDAABAQYAAICDAABAQYAAICDAABAQaAgAADQECAASAgwAAQEGAACAgwAAQEGAACAgwAAQEGgIAAA0BAgAEgIMAAEBBgAAgIMAAEBBgAAgIMAAEBBoCAAANAQIABICDAABAQYAAICDAABAQYAAICDAABAQaAgAADQECAASAgwAAQEGAACAgwAAQEGAACAgwAAQEGgIAAA0BAgAEgIMAAEBBgAAgIMAAEBBgAAgIMAAEBBoCAAANAQIABICDAABAQYAAICDAABAQYAAICDAABAQaAgAADQECAASAgwAAQEGAACAgwAAQEGAACAgwAAQEGgIAAA0BAgAEgIMAAEBBgAAgIMAAEBBgAAgIMAAEBBoCAAANAQIABICDAABAQYAAICDAABAQYAAICDAABAQaAgAADQECAASAgwAAQEGAACAgwAAQEGAACAgwAAQEGgIAAA0BAgAEgIMAAEBBgAAgIMAAEBBgAAgIMAAEBBoCAAANAQIABICDAABAQYAAICDAABAQYAAICDAABAQaAgAADQECAASAgwAAQEGAACAgwAAQEGAACAgwAAQEGgIAAA0BAgAEgIMAAEBBgAAgIMAAEBBgABBgA7uABA0BAgAEgIMAAEBBgAAgIMAAEBBgAAgIMAAEBBoCAAANAQIABICDAABAQYAAICDAABAQYAAICDAABAQYAAQaAO3jAABAQYAAICDAABAQYAAICDAABAQaAgAADQECAASAgwAAQEGAACAgwAAQEGAACAgwAAQEGgIAAA0BAgAEgIMAAEBBgAAgIMAAEBBgAAgIMAAEBBoCAAANAQIABICDAABAQYAAICDAABAQYAAICDAABAQaAgAADQECAASAgwAAQEGAACAgwAAQEGAACAgwAAQEGgIAAA0BAgAEgIMAAEBBgAAgIMAAEBBgAAgIMAAEBBoCAAANAQIABICDAABAQYAAICDAABAQYANa8H4AjBPggNxbsAAAAAElFTkSuQmCC',
7
- 'base64',
8
- );
9
-
10
- test('edit a character and persist its speech preferences', async ({ page }) => {
11
- await page.goto('/characters');
12
- await page.getByRole('button', { name: 'Edit R.Royale' }).click();
13
- await page.getByRole('button', { name: 'Speech style', exact: true }).click();
14
- await page.getByLabel('Regional influence').fill('Creator approved regional expression');
15
- await page.getByRole('button', { name: 'Save character', exact: true }).click();
16
- await expect(page.getByRole('dialog')).not.toBeVisible();
17
- await page.reload();
18
- await page.getByRole('button', { name: 'Edit R.Royale' }).click();
19
- await page.getByRole('button', { name: 'Speech style', exact: true }).click();
20
- await expect(page.getByLabel('Regional influence')).toHaveValue(
21
- 'Creator approved regional expression',
22
- );
23
- });
24
-
25
  test('approve a scene and exact script, render a real storyboard and reload', async ({ page }) => {
26
  await page.goto('/');
27
- await page
28
- .getByLabel('Upload image')
29
- .setInputFiles({ name: 'e2e-fictional-scene.png', mimeType: 'image/png', buffer: image });
30
- await page
31
- .getByLabel('Ownership or authorization details')
32
- .fill('Original synthetic image for automated testing');
33
- await page.getByLabel('I have rights to use this fictional image.').check();
34
- await page.getByRole('button', { name: 'Upload asset', exact: true }).click();
35
- await expect(page.getByRole('img', { name: 'Shared scene preview' })).toBeVisible();
36
- await page.getByLabel('Both fictional characters are visible').check();
37
  await page
38
  .getByLabel('Dialogue line 1', { exact: true })
39
  .fill('A little perspective changes everything.');
40
  await page
41
  .getByLabel('Dialogue line 2', { exact: true })
42
  .fill('And a little sunshine helps, too.');
43
- await expect(page.getByRole('button', { name: 'Create storyboard' })).toBeDisabled();
 
 
44
  await page.getByLabel('I approve these exact words').check();
45
- await page.getByLabel('Duration', { exact: true }).selectOption('10');
46
- await page.getByRole('button', { name: 'Create storyboard' }).click();
47
- await expect(page).toHaveURL(/renders/);
48
  await expect(page.getByText('Storyboard ready — no voice or animation').first()).toBeVisible({
49
  timeout: 60000,
50
  });
@@ -52,6 +22,11 @@ test('approve a scene and exact script, render a real storyboard and reload', as
52
  const response = await page.request.get((await download.getAttribute('href'))!);
53
  expect(response.ok()).toBeTruthy();
54
  expect((await response.body()).subarray(0, 64).includes(Buffer.from('ftyp'))).toBeTruthy();
 
 
 
 
 
55
  await page.reload();
56
  await expect(download).toBeVisible();
57
  });
@@ -59,14 +34,14 @@ test('approve a scene and exact script, render a real storyboard and reload', as
59
  test('mobile navigation and provider status are usable', async ({ page }) => {
60
  await page.setViewportSize({ width: 390, height: 844 });
61
  await page.goto('/settings');
62
- await expect(page.getByRole('heading', { name: 'Your studio, connected.' })).toBeVisible();
63
- await expect(page.getByRole('heading', { name: 'Chatterbox', exact: true })).toBeVisible();
64
  const overflow = await page.evaluate(
65
  () => document.documentElement.scrollWidth > window.innerWidth,
66
  );
67
  expect(overflow).toBe(false);
68
  await page.getByRole('link', { name: 'Characters', exact: true }).click();
69
- await expect(page.getByRole('heading', { name: 'Characters with character.' })).toBeVisible();
70
  });
71
 
72
  test('missing GPU voices are surfaced instead of a fake completed render', async ({ request }) => {
 
1
  import { test, expect } from '@playwright/test';
2
 
3
+ // Actual API, SQLite and FFmpeg worker; inference is tested separately.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  test('approve a scene and exact script, render a real storyboard and reload', async ({ page }) => {
5
  await page.goto('/');
 
 
 
 
 
 
 
 
 
 
6
  await page
7
  .getByLabel('Dialogue line 1', { exact: true })
8
  .fill('A little perspective changes everything.');
9
  await page
10
  .getByLabel('Dialogue line 2', { exact: true })
11
  .fill('And a little sunshine helps, too.');
12
+ await expect(page.getByRole('button', { name: 'Create talking video' })).toBeDisabled();
13
+ await page.getByText('Optional silent storyboard preview', { exact: true }).click();
14
+ await expect(page.getByRole('button', { name: 'Create silent storyboard' })).toBeDisabled();
15
  await page.getByLabel('I approve these exact words').check();
16
+ await expect(page.getByRole('button', { name: 'Create talking video' })).toBeDisabled();
17
+ await page.getByRole('button', { name: 'Create silent storyboard' }).click();
 
18
  await expect(page.getByText('Storyboard ready — no voice or animation').first()).toBeVisible({
19
  timeout: 60000,
20
  });
 
22
  const response = await page.request.get((await download.getAttribute('href'))!);
23
  expect(response.ok()).toBeTruthy();
24
  expect((await response.body()).subarray(0, 64).includes(Buffer.from('ftyp'))).toBeTruthy();
25
+ const preview = page.locator('video');
26
+ await expect
27
+ .poll(() => preview.evaluate((element: HTMLVideoElement) => element.duration))
28
+ .toBeLessThan(10);
29
+ await page.goto('/renders');
30
  await page.reload();
31
  await expect(download).toBeVisible();
32
  });
 
34
  test('mobile navigation and provider status are usable', async ({ page }) => {
35
  await page.setViewportSize({ width: 390, height: 844 });
36
  await page.goto('/settings');
37
+ await expect(page.getByRole('heading', { name: 'Settings', exact: true })).toBeVisible();
38
+ await expect(page.getByRole('heading', { name: 'kokoro', exact: true })).toBeVisible();
39
  const overflow = await page.evaluate(
40
  () => document.documentElement.scrollWidth > window.innerWidth,
41
  );
42
  expect(overflow).toBe(false);
43
  await page.getByRole('link', { name: 'Characters', exact: true }).click();
44
+ await expect(page.getByRole('heading', { name: 'Characters', exact: true })).toBeVisible();
45
  });
46
 
47
  test('missing GPU voices are surfaced instead of a fake completed render', async ({ request }) => {
frontend/src/features/generations/renders.page.tsx CHANGED
@@ -75,7 +75,10 @@ export function RendersPage() {
75
  {job.settings.kind === 'storyboard'
76
  ? 'Silent storyboard · no speech or animation'
77
  : 'AI-generated conversation · review required'}{' '}
78
- · {job.duration?.toFixed(1) || job.settings.target_seconds}s
 
 
 
79
  </p>
80
  <div
81
  className="progress"
 
75
  {job.settings.kind === 'storyboard'
76
  ? 'Silent storyboard · no speech or animation'
77
  : 'AI-generated conversation · review required'}{' '}
78
+ ·{' '}
79
+ {job.duration != null
80
+ ? `${job.duration.toFixed(1)}s`
81
+ : `Up to ${job.settings.target_seconds}s`}
82
  </p>
83
  <div
84
  className="progress"
frontend/src/features/generations/studio.page.tsx CHANGED
@@ -28,7 +28,6 @@ export function StudioPage() {
28
  ],
29
  });
30
  const [scriptId, setScriptId] = useState<string>();
31
- const [seconds, setSeconds] = useState(60);
32
  const [busy, setBusy] = useState(false);
33
  const [error, setError] = useState<unknown>();
34
  const [notice, setNotice] = useState('');
@@ -55,7 +54,7 @@ export function StudioPage() {
55
  const remaining = !sceneValid
56
  ? 'The demo scene is not available. Check the backend connection.'
57
  : !scriptValid
58
- ? 'Give your conversation a name and fill in each line. Aim for about 120–140 words for 60 seconds.'
59
  : !matchingSpeakers
60
  ? 'Give both characters at least one line.'
61
  : !script.approved
@@ -78,9 +77,13 @@ export function StudioPage() {
78
  setScriptId(conversation.id);
79
  await query.invalidateQueries({ queryKey: ['conversations'] });
80
  if (kind && scene) {
81
- const generation = await api.generate(conversation.id, DEMO_SCENE_ID, kind, seconds);
82
  setJobId(generation.id);
83
- setNotice('Conversation saved. Your preview is queued below.');
 
 
 
 
84
  } else setNotice('Conversation saved.');
85
  } catch (e) {
86
  setError(e);
@@ -126,19 +129,11 @@ export function StudioPage() {
126
  </div>
127
  <div className="panel-content">
128
  <div className="simple-export-row">
129
- <label>
130
- Duration
131
- <select value={seconds} onChange={(e) => setSeconds(+e.target.value)}>
132
- <option value={10}>10 seconds</option>
133
- <option value={60}>60 seconds</option>
134
- </select>
135
- </label>
136
  <p>
137
- The storyboard is a silent scene preview.
138
  <br />
139
- {capabilities.animation
140
- ? 'Talking videos animate both portraits separately with speech and lip-sync.'
141
- : 'Speaking and lip-sync are not available yet.'}
142
  </p>
143
  </div>
144
  {remaining && <p className="next-step">{remaining}</p>}
@@ -151,32 +146,39 @@ export function StudioPage() {
151
  <Save size={16} />
152
  {busy ? 'Saving…' : 'Save draft'}
153
  </button>
154
- <UnavailableFeature reason={capabilities.workerReason}>
155
  <button
156
  className="button primary"
157
  disabled={busy || !ready}
158
- onClick={() => save('storyboard')}
159
  >
160
- Create storyboard
161
  <ArrowRight size={16} />
162
  </button>
163
  </UnavailableFeature>
164
- <UnavailableFeature reason={capabilities.animationReason || capabilities.workerReason}>
 
 
 
 
 
 
 
165
  <button
166
  className="button secondary"
167
  disabled={busy || !ready}
168
- onClick={() => save('animated')}
169
  >
170
- Create talking video
171
  </button>
172
  </UnavailableFeature>
173
- </div>
174
  </div>
175
  </section>
176
  {jobId && (
177
  <section className="panel">
178
  <div className="panel-header">
179
- <h2>Your preview</h2>
180
  </div>
181
  <div className="panel-content">
182
  <ErrorNotice error={job.error} />
 
28
  ],
29
  });
30
  const [scriptId, setScriptId] = useState<string>();
 
31
  const [busy, setBusy] = useState(false);
32
  const [error, setError] = useState<unknown>();
33
  const [notice, setNotice] = useState('');
 
54
  const remaining = !sceneValid
55
  ? 'The demo scene is not available. Check the backend connection.'
56
  : !scriptValid
57
+ ? 'Give your conversation a name and fill in each line. Videos follow the conversation length, up to 60 seconds.'
58
  : !matchingSpeakers
59
  ? 'Give both characters at least one line.'
60
  : !script.approved
 
77
  setScriptId(conversation.id);
78
  await query.invalidateQueries({ queryKey: ['conversations'] });
79
  if (kind && scene) {
80
+ const generation = await api.generate(conversation.id, DEMO_SCENE_ID, kind, 60);
81
  setJobId(generation.id);
82
+ setNotice(
83
+ kind === 'animated'
84
+ ? 'Talking video queued with speech and lip-sync.'
85
+ : 'Silent storyboard preview queued.',
86
+ );
87
  } else setNotice('Conversation saved.');
88
  } catch (e) {
89
  setError(e);
 
129
  </div>
130
  <div className="panel-content">
131
  <div className="simple-export-row">
 
 
 
 
 
 
 
132
  <p>
133
+ Video length follows your spoken dialogue and pauses, up to 60 seconds.
134
  <br />
135
+ Talking videos include voices and lip-sync for both characters. Short conversations
136
+ produce short videos, without padding to a minute.
 
137
  </p>
138
  </div>
139
  {remaining && <p className="next-step">{remaining}</p>}
 
146
  <Save size={16} />
147
  {busy ? 'Saving…' : 'Save draft'}
148
  </button>
149
+ <UnavailableFeature reason={capabilities.animationReason || capabilities.workerReason}>
150
  <button
151
  className="button primary"
152
  disabled={busy || !ready}
153
+ onClick={() => save('animated')}
154
  >
155
+ Create talking video
156
  <ArrowRight size={16} />
157
  </button>
158
  </UnavailableFeature>
159
+ </div>
160
+ <details>
161
+ <summary>Optional silent storyboard preview</summary>
162
+ <p>
163
+ This creates a still image video without voices or lip-sync. Duration is estimated
164
+ from the script.
165
+ </p>
166
+ <UnavailableFeature reason={capabilities.workerReason}>
167
  <button
168
  className="button secondary"
169
  disabled={busy || !ready}
170
+ onClick={() => save('storyboard')}
171
  >
172
+ Create silent storyboard
173
  </button>
174
  </UnavailableFeature>
175
+ </details>
176
  </div>
177
  </section>
178
  {jobId && (
179
  <section className="panel">
180
  <div className="panel-header">
181
+ <h2>Your render</h2>
182
  </div>
183
  <div className="panel-content">
184
  <ErrorNotice error={job.error} />
scripts/run_e2e_server.py CHANGED
@@ -15,6 +15,8 @@ with tempfile.TemporaryDirectory(prefix="character-e2e-") as folder:
15
  "DATABASE_URL": "sqlite:///" + folder + "/app.db",
16
  "ASSETS_DIR": folder + "/assets",
17
  "SEED_CHARACTERS": "true",
 
 
18
  "SPEECH_URL": "",
19
  "VIDEO_URL": "",
20
  }
 
15
  "DATABASE_URL": "sqlite:///" + folder + "/app.db",
16
  "ASSETS_DIR": folder + "/assets",
17
  "SEED_CHARACTERS": "true",
18
+ "FIXED_DEMO_MODE": "true",
19
+ "ENABLE_ANIMATED_RENDERS": "false",
20
  "SPEECH_URL": "",
21
  "VIDEO_URL": "",
22
  }