Fix speaking by using heygen api v2.

This commit is contained in:
Cristiano Ferreira
2024-01-03 16:23:26 +00:00
parent 479620116d
commit 9b3997f65e
2 changed files with 20 additions and 17 deletions

View File

@@ -92,23 +92,26 @@ def create_videos_and_save_to_db(exercises, template, id):
template["exercises"][2]["title"] = exercises[2]["topic"]
save_to_db_with_id("speaking", template, id)
app.app.logger.info('Saved speaking to DB with id ' + id + " : " + str(template))
def create_video(text, avatar: AvatarEnum):
# POST TO CREATE VIDEO
create_video_url = 'https://api.heygen.com/v2/template/' + avatar.value + '/generate'
data = {
"template_id": avatar.value,
"title": "video_title",
"test": False,
"variables": [
{
"caption": False,
"title": "video_title",
"variables": {
"script_here": {
"name": "script_here",
"type": "text",
"properties": {
"text": text
},
"name": "avatar_0"
"content": text
}
}
]
}
}
response = requests.post(CREATE_VIDEO_URL, headers=POST_HEADER, json=data)
response = requests.post(create_video_url, headers=POST_HEADER, json=data)
app.app.logger.info(response.status_code)
app.app.logger.info(response.json())
@@ -130,7 +133,7 @@ def create_video(text, avatar: AvatarEnum):
if status != "completed" and error is None:
app.app.logger.info(f"Status: {status}")
time.sleep(5) # Wait for 5 second before the next request
time.sleep(10) # Wait for 10 second before the next request
app.app.logger.info(response.status_code)
app.app.logger.info(response.json())