From 30fba33223f991c93abad1db66e89eaa817b96f9 Mon Sep 17 00:00:00 2001 From: Sergiy Date: Thu, 26 Sep 2024 21:36:07 +0300 Subject: [PATCH 1/3] OV-455: + helper --- .../helpers/are-all-scenes-with-scenes.helper.ts | 7 +++++++ frontend/src/bundles/studio/helpers/helpers.ts | 1 + frontend/src/bundles/studio/pages/studio.tsx | 14 ++++++++------ 3 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 frontend/src/bundles/studio/helpers/are-all-scenes-with-scenes.helper.ts diff --git a/frontend/src/bundles/studio/helpers/are-all-scenes-with-scenes.helper.ts b/frontend/src/bundles/studio/helpers/are-all-scenes-with-scenes.helper.ts new file mode 100644 index 000000000..60271a87e --- /dev/null +++ b/frontend/src/bundles/studio/helpers/are-all-scenes-with-scenes.helper.ts @@ -0,0 +1,7 @@ +import { type Scene } from '../types/types.js'; + +function areAllScenesWithAvatar(scenes: Scene[]): boolean { + return scenes.every((scene) => scene.avatar !== undefined); +} + +export { areAllScenesWithAvatar }; diff --git a/frontend/src/bundles/studio/helpers/helpers.ts b/frontend/src/bundles/studio/helpers/helpers.ts index 00ac68474..7a14da2ba 100644 --- a/frontend/src/bundles/studio/helpers/helpers.ts +++ b/frontend/src/bundles/studio/helpers/helpers.ts @@ -1,5 +1,6 @@ export { addScene } from './add-scene.js'; export { addScript } from './add-script.js'; +export { areAllScenesWithAvatar } from './are-all-scenes-with-scenes.helper.js'; export { createDefaultAvatarFromRequest } from './create-default-avatar.js'; export { getDestinationPointerValue } from './get-destination-pointer-value.js'; export { getElementEnd } from './get-element-end.js'; diff --git a/frontend/src/bundles/studio/pages/studio.tsx b/frontend/src/bundles/studio/pages/studio.tsx index 112d30abe..837916138 100644 --- a/frontend/src/bundles/studio/pages/studio.tsx +++ b/frontend/src/bundles/studio/pages/studio.tsx @@ -46,7 +46,11 @@ import { VIDEO_SUBMIT_NOTIFICATION_ID, } from '../constants/constants.js'; import { NotificationMessage, NotificationTitle } from '../enums/enums.js'; -import { getVoicesConfigs, scenesExceedScripts } from '../helpers/helpers.js'; +import { + areAllScenesWithAvatar, + getVoicesConfigs, + scenesExceedScripts, +} from '../helpers/helpers.js'; import { selectVideoDataById } from '../store/selectors.js'; import { actions as studioActions } from '../store/studio.js'; @@ -93,15 +97,14 @@ const Studio: React.FC = () => { const handleConfirmSubmit = useCallback(() => { // TODO: REPLACE LOGIC WITH MULTIPLE SCENES - const scene = scenes[0]; + const script = scripts[0]; - if (!scene?.avatar || !script) { - notificationService.warn({ + if (!areAllScenesWithAvatar(scenes) || !script) { + return notificationService.warn({ id: SCRIPT_AND_AVATAR_ARE_REQUIRED, message: NotificationMessage.SCRIPT_AND_AVATAR_ARE_REQUIRED, title: NotificationTitle.SCRIPT_AND_AVATAR_ARE_REQUIRED, }); - return; } void dispatch(studioActions.generateAllScriptsSpeech()) @@ -158,7 +161,6 @@ const Studio: React.FC = () => { composition: { scenes, scripts: getVoicesConfigs(scripts), - // TODO : CHANGE TO ENUM videoOrientation: videoSize, }, name: videoName, From 1eb7b375cf5fb0b6a4ba013ed317178474e33fa8 Mon Sep 17 00:00:00 2001 From: Sergiy Date: Thu, 26 Sep 2024 21:37:52 +0300 Subject: [PATCH 2/3] OV-455: * script processor --- .../services/script-processor.service.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/backend/src/bundles/avatar-videos/services/script-processor.service.ts b/backend/src/bundles/avatar-videos/services/script-processor.service.ts index 16344051e..9ef10e623 100644 --- a/backend/src/bundles/avatar-videos/services/script-processor.service.ts +++ b/backend/src/bundles/avatar-videos/services/script-processor.service.ts @@ -73,7 +73,21 @@ class ScriptProcessor { voice: string; scene: Scene; }): void { - if (text && this.currentAvatar) { + if (!text || !this.currentAvatar) { + return; + } + + const lastScene = this.result.at(-1); + + if ( + lastScene && + lastScene.avatar.voice === voice && + lastScene.avatar.name === this.currentAvatar.name && + JSON.stringify(lastScene.background) === + JSON.stringify(scene.background) + ) { + lastScene.avatar.text += ' ' + text; + } else { this.result.push({ ...scene, id: uuidv4(), From 11612b747c6b0936cbe75913f8ca06b24c5a5cbf Mon Sep 17 00:00:00 2001 From: Sergiy Date: Fri, 27 Sep 2024 09:38:54 +0300 Subject: [PATCH 3/3] OV-455: * script-processor --- .../bundles/avatar-videos/services/script-processor.service.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/src/bundles/avatar-videos/services/script-processor.service.ts b/backend/src/bundles/avatar-videos/services/script-processor.service.ts index 9ef10e623..26fe4df59 100644 --- a/backend/src/bundles/avatar-videos/services/script-processor.service.ts +++ b/backend/src/bundles/avatar-videos/services/script-processor.service.ts @@ -83,6 +83,7 @@ class ScriptProcessor { lastScene && lastScene.avatar.voice === voice && lastScene.avatar.name === this.currentAvatar.name && + lastScene.avatar.style === this.currentAvatar.style && JSON.stringify(lastScene.background) === JSON.stringify(scene.background) ) {