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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
let the fal lip-sync model run from Video Gen with an uploaded voice clip
[._.]/ Adam Eivy84e996100206
diff --git a/server/services/videoGen/fal.js b/server/services/videoGen/fal.jsindex 2d412a765b..129339209b 100644--- a/server/services/videoGen/fal.js+++ b/server/services/videoGen/fal.js@@ -257,6 +257,12 @@ export async function generateVideo({};}+// The staged voice clip keeps its upload's extension (a performance slice is always WAV).+export function audioMimeType(path) {+ const ext = String(path).toLowerCase().split('.').pop();+ return { mp3: 'audio/mpeg', m4a: 'audio/mp4', mp4: 'audio/mp4', aac: 'audio/aac', ogg: 'audio/ogg', flac: 'audio/flac' }[ext] || 'audio/wav';+}+async function runFalVideo(job, jobId, {apiKey, modelId, prompt, negativePrompt, duration, aspectRatio, sourceImagePath, outputPath, filename, meta,audioFilePath = null, enableTranscription = false, requestSpec = null,@@ -268,7 +274,7 @@ async function runFalVideo(job, jobId, {try {const imageDataUri = sourceImagePath ? await fileToDataUri(sourceImagePath) : null;const audioDataUri = audioFilePath- ? `data:audio/wav;base64,${(await readFile(audioFilePath)).toString('base64')}`+ ? `data:${audioMimeType(audioFilePath)};base64,${(await readFile(audioFilePath)).toString('base64')}`: null;const body = requestSpec? buildFalVideoRequest({ ...requestSpec, imageUrl: imageDataUri, audioUrl: audioDataUri }).bodydiff --git a/server/services/videoGen/fal.test.js b/server/services/videoGen/fal.test.jsindex 89499275db..4f2c869561 100644--- a/server/services/videoGen/fal.test.js+++ b/server/services/videoGen/fal.test.js@@ -676,3 +676,13 @@ describe('videoGen/fal — recover completed renders (#8564)', () => {await expect(readFile(join(FAKE_VIDEOS_DIR, job.filename))).rejects.toMatchObject({ code: 'ENOENT' });});});++describe('audioMimeType', () => {+ it('labels the staged voice clip by its extension, WAV by default', async () => {+ const { audioMimeType } = await import('./fal.js');+ expect(audioMimeType('/u/video-audio-1.mp3')).toBe('audio/mpeg');+ expect(audioMimeType('/u/video-audio-1.M4A')).toBe('audio/mp4');+ expect(audioMimeType('/u/slice.wav')).toBe('audio/wav');+ expect(audioMimeType('/u/clip')).toBe('audio/wav');+ });+});diff --git a/server/services/videoGen/prepareParams.js b/server/services/videoGen/prepareParams.jsindex 25516dd551..e508d0cfe6 100644--- a/server/services/videoGen/prepareParams.js+++ b/server/services/videoGen/prepareParams.js@@ -52,6 +52,7 @@ import { getSettings } from '../settings.js';import { getProject as getMusicVideoProject } from '../musicVideo/projects.js';import { getTrack } from '../tracks/index.js';import { VIDEO_GEN_MODE, resolveVideoMode } from './modes.js';+import { getFalVideoModel } from '../../lib/falVideoModels.js';import { HOSTED_VIDEO_SUBMISSIONS } from './hostedSubmission.js';import { isDefaultI2vReferenceMode } from '../../lib/videoReferenceModes.js';import {@@ -458,7 +459,13 @@ async function resolvePreparedParams({{ status: 400, code: 'VIDEO_GEN_AUDIO_REQUIRED' },);}- if (uploads.audioFile && body.mode !== 'a2v') {+ // A fal lip-sync model takes the frame plus an uploaded voice clip (no Music Video scene needed).+ const falLipSync = body.backend === VIDEO_GEN_MODE.FAL && getFalVideoModel(body.falModelId)?.kind === 'lipsync';+ if (falLipSync && !uploads.audioFile && !body.musicVideo) {+ await cleanupStaged();+ throw new ServerError('A fal.ai lip-sync model needs an audioFile upload (the voice to sync to).', { status: 400, code: 'VIDEO_GEN_AUDIO_REQUIRED' });+ }+ if (uploads.audioFile && body.mode !== 'a2v' && !falLipSync) {await cleanupStaged();throw new ServerError(`audioFile upload is only valid with mode='a2v' (got mode='${body.mode || 'unset'}').`,@@ -741,12 +748,23 @@ async function resolvePreparedParams({await cleanupStaged();throw new ServerError(hosted.errorMessage, { status: 400, code: hosted.errorCode });}+ // A standalone fal lip-sync take: stage the voice clip durably like the frame. The queue owns+ // and removes it with the job (uploadedTempPaths), as it does for the local a2v lane.+ let hostedAudioPath = null;+ if (falLipSync && uploads.audioFile) {+ if (!sourceImagePath) {+ await cleanupStaged();+ throw new ServerError('A fal.ai lip-sync render needs a reference frame (sourceImage or sourceImageFile).', { status: 400, code: 'VALIDATION_ERROR' });+ }+ hostedAudioPath = await stageUploadDurable(uploads.audioFile, 'audio');+ }return {backend,...extras,effectiveModel: { id: backend, supportedModes: ['text', 'image'] },sourceImagePath,uploadedTempPath,+ ...(hostedAudioPath ? { audioFilePath: hostedAudioPath, uploadedTempPaths: [hostedAudioPath] } : {}),discardSourceImage,cleanupStaged,};diff --git a/server/services/videoGen/prepareParams.test.js b/server/services/videoGen/prepareParams.test.jsindex 1b6fe137b0..4d75cfc616 100644--- a/server/services/videoGen/prepareParams.test.js+++ b/server/services/videoGen/prepareParams.test.js@@ -708,3 +708,38 @@ describe('prepareVideoGenParams — i2v reference mode (#4874)', () => {})).rejects.toMatchObject({ status: 400, code: 'I2V_REFERENCE_MODE_REQUIRES_IMAGE' });});});++describe('prepareVideoGenParams — standalone fal lip sync', () => {+ const LIPSYNC = 'minimax/h3-max/lip-sync/image-to-video';+ const falSettings = () => ({ imageGen: { local: { pythonPath: '/usr/bin/python3' } }, videoGen: { fal: { apiKey: 'test-key' } } });+ beforeEach(() => { copyFileMock.mockClear(); unlinkMock.mockClear(); });++ it('stages the uploaded voice clip next to the frame and hands both to the hosted job', async () => {+ getSettings.mockResolvedValueOnce(falSettings());+ const prepared = await prepare(+ { backend: 'fal', falModelId: LIPSYNC, mode: 'image', sourceImageFile: 'face.png' },+ { audioFile: upload('audioFile', 'line.wav') },+ );+ expect(prepared.backend).toBe('fal');+ expect(posix(prepared.sourceImagePath)).toBe('/mock/images/face.png');+ expect(posix(prepared.audioFilePath)).toMatch(/^\/mock\/uploads\/video-audio-.+\.wav$/);+ expect(prepared.uploadedTempPaths).toEqual([prepared.audioFilePath]);+ });++ it('refuses a lip-sync model without a voice clip, and a voice clip without a lip-sync model', async () => {+ getSettings.mockResolvedValueOnce(falSettings());+ await expect(prepare({ backend: 'fal', falModelId: LIPSYNC, mode: 'image', sourceImageFile: 'face.png' }))+ .rejects.toMatchObject({ status: 400, code: 'VIDEO_GEN_AUDIO_REQUIRED' });+ getSettings.mockResolvedValueOnce(falSettings());+ await expect(prepare(+ { backend: 'fal', falModelId: 'fal-ai/minimax/hailuo-02/standard/image-to-video', mode: 'image', sourceImageFile: 'face.png' },+ { audioFile: upload('audioFile', 'line.wav') },+ )).rejects.toMatchObject({ status: 400, code: 'VIDEO_GEN_AUDIO_MODE_MISMATCH' });+ });++ it('needs a reference frame for the lip sync', async () => {+ getSettings.mockResolvedValueOnce(falSettings());+ await expect(prepare({ backend: 'fal', falModelId: LIPSYNC, mode: 'text' }, { audioFile: upload('audioFile', 'line.wav') }))+ .rejects.toMatchObject({ status: 400, code: 'VALIDATION_ERROR' });+ });+});diff --git a/server/services/videoGen/submitJob.js b/server/services/videoGen/submitJob.jsindex f670d047c0..974a9b076b 100644--- a/server/services/videoGen/submitJob.js+++ b/server/services/videoGen/submitJob.js@@ -354,6 +354,8 @@ const submitValidatedVideoGenJob = async (body, uploads) => {...(body.fableLoom ? { fableLoom: body.fableLoom } : {}),...(body.visualConditioning ? { visualConditioning: body.visualConditioning } : {}),...hosted.buildParams(body, prepared),+ // standalone fal lip sync: the uploaded voice clip (a Music Video performance shot overrides below)+ ...(prepared.audioFilePath ? { audioFilePath: prepared.audioFilePath, uploadedTempPaths: prepared.uploadedTempPaths, lipSync: { enableTranscription: false } } : {}),...performanceParams,});return {diff --git a/server/services/videoGen/submitJob.test.js b/server/services/videoGen/submitJob.test.jsindex 3a879bf956..ddb8d02742 100644--- a/server/services/videoGen/submitJob.test.js+++ b/server/services/videoGen/submitJob.test.js@@ -198,6 +198,20 @@ describe('submitVideoGenJob', () => {expect(prepared.cleanupStaged).toHaveBeenCalledTimes(1);});+ it('enqueues a standalone fal lip sync with the staged voice clip, owned by the queue', async () => {+ mocks.prepareVideoGenParams.mockResolvedValue({+ backend: 'fal', cleanupStaged: vi.fn(async () => {}), sourceImagePath: '/example/images/face.png', uploadedTempPath: null,+ audioFilePath: '/example/uploads/video-audio-1.wav', uploadedTempPaths: ['/example/uploads/video-audio-1.wav'],+ });+ await submitVideoGenJob({ prompt: 'lip sync', backend: 'fal', falModelId: 'minimax/h3-max/lip-sync/image-to-video', mode: 'image' }, {});+ const { params } = mocks.enqueueJob.mock.calls.at(-1)[0];+ expect(params).toMatchObject({+ mode: 'fal', modelId: 'minimax/h3-max/lip-sync/image-to-video', sourceImagePath: '/example/images/face.png',+ audioFilePath: '/example/uploads/video-audio-1.wav', uploadedTempPaths: ['/example/uploads/video-audio-1.wav'],+ lipSync: { enableTranscription: false },+ });+ });+describe('music-video performance shots (#8977)', () => {const musicVideo = { projectId: 'mv-1', sceneId: 'mvs-1' };const falPrepared = () => ({