Update video generation to use heygen.

This commit is contained in:
Cristiano Ferreira
2024-11-07 23:32:44 +00:00
parent 2263c55776
commit 81a74c5f3b
3 changed files with 10 additions and 12 deletions

View File

@@ -417,14 +417,14 @@ class SpeakingService(ISpeakingService):
return response["fixed_text"]
async def create_videos_and_save_to_db(self, exercises, template, req_id):
template = await self._create_video_per_part(exercises, template, 1)
template = await self._create_video_per_part(exercises, template, 2)
template = await self._create_video_per_part(exercises, template, 3)
template = await self._create_video_per_part(exercises, template, 1, req_id)
template = await self._create_video_per_part(exercises, template, 2, req_id)
template = await self._create_video_per_part(exercises, template, 3, req_id)
await self._document_store.save_to_db_with_id("speaking", template, req_id)
self._logger.info(f'Saved speaking to DB with id {req_id} : {str(template)}')
async def _create_video_per_part(self, exercises: List[Dict], template: Dict, part: int):
async def _create_video_per_part(self, exercises: List[Dict], template: Dict, part: int, req_id: str):
avatar = (random.choice(list(ELAIAvatars))).name
template_index = part - 1
@@ -441,7 +441,8 @@ class SpeakingService(ISpeakingService):
result = await self._create_video(
question,
avatar,
f'Failed to create video for part {part} question: {str(exercise["question"])}'
f'Failed to create video for part {part} question: {str(exercise["question"])}',
req_id
)
if result is not None:
video = {
@@ -588,8 +589,8 @@ class SpeakingService(ISpeakingService):
response["id"] = str(uuid.uuid4())
return response
async def _create_video(self, question: str, avatar: str, error_message: str):
result = await self._vid_gen.create_video(question, avatar)
async def _create_video(self, question: str, avatar: str, error_message: str, title: str):
result = await self._vid_gen.create_video(question, avatar, title)
if result is not None:
sound_file_path = FilePaths.VIDEO_FILES_PATH + result
firebase_file_path = FilePaths.FIREBASE_SPEAKING_VIDEO_FILES_PATH + result