Fix speaking by using heygen api v2.
This commit is contained in:
@@ -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())
|
||||
|
||||
@@ -2,10 +2,10 @@ from enum import Enum
|
||||
|
||||
|
||||
class AvatarEnum(Enum):
|
||||
MATTHEW_NOAH = "11b234e504e44bfda9bc6b7aac3c8f81"
|
||||
VERA_CERISE = "9bf2f27009cd403ab4ba4e22629b27bb"
|
||||
EDWARD_TONY = "d3333e37952946059b45efc8482a2b6c"
|
||||
TANYA_MOLLY = "07c75076b3f94df4ac658c6de72be83a"
|
||||
KAYLA_ABBI = "d688099f8db9472cb4890b0561e81793"
|
||||
JEROME_RYAN = "ad41feb2a5c4483085525e3d8907f512"
|
||||
TYLER_CHRISTOPHER = "03c796f8ed274bb38f19e893bcbc6121"
|
||||
MATTHEW_NOAH = "5912afa7c77c47d3883af3d874047aaf"
|
||||
VERA_CERISE = "9e58d96a383e4568a7f1e49df549e0e4"
|
||||
EDWARD_TONY = "d2cdd9c0379a4d06ae2afb6e5039bd0c"
|
||||
TANYA_MOLLY = "045cb5dcd00042b3a1e4f3bc1c12176b"
|
||||
KAYLA_ABBI = "1ae1e5396cc444bfad332155fdb7a934"
|
||||
JEROME_RYAN = "0ee6aa7cc1084063a630ae514fccaa31"
|
||||
TYLER_CHRISTOPHER = "5772cff935844516ad7eeff21f839e43"
|
||||
|
||||
Reference in New Issue
Block a user