Skip to content

Commit

Permalink
Merge branch 'next' into task/OV-439-generate-preview-for-template
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiy4 committed Sep 27, 2024
2 parents 73c6341 + e8df78a commit a74dc6d
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,22 @@ 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 &&
lastScene.avatar.style === this.currentAvatar.style &&
JSON.stringify(lastScene.background) ===
JSON.stringify(scene.background)
) {
lastScene.avatar.text += ' ' + text;
} else {
this.result.push({
...scene,
id: uuidv4(),
Expand Down
Original file line number Diff line number Diff line change
@@ -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 };
1 change: 1 addition & 0 deletions frontend/src/bundles/studio/helpers/helpers.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
14 changes: 8 additions & 6 deletions frontend/src/bundles/studio/pages/studio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -158,7 +161,6 @@ const Studio: React.FC = () => {
composition: {
scenes,
scripts: getVoicesConfigs(scripts),
// TODO : CHANGE TO ENUM
videoOrientation: videoSize,
},
name: videoName,
Expand Down

0 comments on commit a74dc6d

Please sign in to comment.