Change speaking to receive avatar from frontend.

This commit is contained in:
Cristiano Ferreira
2024-02-09 00:13:07 +00:00
parent d532f7deb4
commit b46f6011d3
2 changed files with 5 additions and 4 deletions

5
app.py
View File

@@ -602,7 +602,8 @@ def save_speaking():
def generate_speaking_video(): def generate_speaking_video():
try: try:
data = request.get_json() data = request.get_json()
sp1_result = create_video(data["question"], random.choice(list(AvatarEnum))) avatar = data.get("avatar", random.choice(list(AvatarEnum)).value)
sp1_result = create_video(data["question"], avatar)
if sp1_result is not None: if sp1_result is not None:
sound_file_path = VIDEO_FILES_PATH + sp1_result sound_file_path = VIDEO_FILES_PATH + sp1_result
firebase_file_path = FIREBASE_SPEAKING_VIDEO_FILES_PATH + sp1_result firebase_file_path = FIREBASE_SPEAKING_VIDEO_FILES_PATH + sp1_result
@@ -633,7 +634,7 @@ def generate_interactive_video():
try: try:
data = request.get_json() data = request.get_json()
sp3_questions = [] sp3_questions = []
avatar = random.choice(list(AvatarEnum)) avatar = data.get("avatar", random.choice(list(AvatarEnum)).value)
app.logger.info('Creating videos for speaking part 3') app.logger.info('Creating videos for speaking part 3')
for question in data["questions"]: for question in data["questions"]:

View File

@@ -117,9 +117,9 @@ def create_videos_and_save_to_db(exercises, template, id):
save_to_db_with_id("speaking", template, id) save_to_db_with_id("speaking", template, id)
app.app.logger.info('Saved speaking to DB with id ' + id + " : " + str(template)) app.app.logger.info('Saved speaking to DB with id ' + id + " : " + str(template))
def create_video(text, avatar: AvatarEnum): def create_video(text, avatar):
# POST TO CREATE VIDEO # POST TO CREATE VIDEO
create_video_url = 'https://api.heygen.com/v2/template/' + avatar.value + '/generate' create_video_url = 'https://api.heygen.com/v2/template/' + avatar + '/generate'
data = { data = {
"test": False, "test": False,
"caption": False, "caption": False,