Skip to content

Commit a74dc6d

Browse files
committed
Merge branch 'next' into task/OV-439-generate-preview-for-template
2 parents 73c6341 + e8df78a commit a74dc6d

File tree

4 files changed

+32
-7
lines changed

4 files changed

+32
-7
lines changed

backend/src/bundles/avatar-videos/services/script-processor.service.ts

+16-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,22 @@ class ScriptProcessor {
7373
voice: string;
7474
scene: Scene;
7575
}): void {
76-
if (text && this.currentAvatar) {
76+
if (!text || !this.currentAvatar) {
77+
return;
78+
}
79+
80+
const lastScene = this.result.at(-1);
81+
82+
if (
83+
lastScene &&
84+
lastScene.avatar.voice === voice &&
85+
lastScene.avatar.name === this.currentAvatar.name &&
86+
lastScene.avatar.style === this.currentAvatar.style &&
87+
JSON.stringify(lastScene.background) ===
88+
JSON.stringify(scene.background)
89+
) {
90+
lastScene.avatar.text += ' ' + text;
91+
} else {
7792
this.result.push({
7893
...scene,
7994
id: uuidv4(),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { type Scene } from '../types/types.js';
2+
3+
function areAllScenesWithAvatar(scenes: Scene[]): boolean {
4+
return scenes.every((scene) => scene.avatar !== undefined);
5+
}
6+
7+
export { areAllScenesWithAvatar };

frontend/src/bundles/studio/helpers/helpers.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export { addScene } from './add-scene.js';
22
export { addScript } from './add-script.js';
3+
export { areAllScenesWithAvatar } from './are-all-scenes-with-scenes.helper.js';
34
export { createDefaultAvatarFromRequest } from './create-default-avatar.js';
45
export { getDestinationPointerValue } from './get-destination-pointer-value.js';
56
export { getElementEnd } from './get-element-end.js';

frontend/src/bundles/studio/pages/studio.tsx

+8-6
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ import {
4646
VIDEO_SUBMIT_NOTIFICATION_ID,
4747
} from '../constants/constants.js';
4848
import { NotificationMessage, NotificationTitle } from '../enums/enums.js';
49-
import { getVoicesConfigs, scenesExceedScripts } from '../helpers/helpers.js';
49+
import {
50+
areAllScenesWithAvatar,
51+
getVoicesConfigs,
52+
scenesExceedScripts,
53+
} from '../helpers/helpers.js';
5054
import { selectVideoDataById } from '../store/selectors.js';
5155
import { actions as studioActions } from '../store/studio.js';
5256

@@ -93,15 +97,14 @@ const Studio: React.FC = () => {
9397

9498
const handleConfirmSubmit = useCallback(() => {
9599
// TODO: REPLACE LOGIC WITH MULTIPLE SCENES
96-
const scene = scenes[0];
100+
97101
const script = scripts[0];
98-
if (!scene?.avatar || !script) {
99-
notificationService.warn({
102+
if (!areAllScenesWithAvatar(scenes) || !script) {
103+
return notificationService.warn({
100104
id: SCRIPT_AND_AVATAR_ARE_REQUIRED,
101105
message: NotificationMessage.SCRIPT_AND_AVATAR_ARE_REQUIRED,
102106
title: NotificationTitle.SCRIPT_AND_AVATAR_ARE_REQUIRED,
103107
});
104-
return;
105108
}
106109

107110
void dispatch(studioActions.generateAllScriptsSpeech())
@@ -158,7 +161,6 @@ const Studio: React.FC = () => {
158161
composition: {
159162
scenes,
160163
scripts: getVoicesConfigs(scripts),
161-
// TODO : CHANGE TO ENUM
162164
videoOrientation: videoSize,
163165
},
164166
name: videoName,

0 commit comments

Comments
 (0)