Update video generation to generate from template.

This commit is contained in:
Cristiano Ferreira
2023-09-25 22:37:55 +01:00
parent 035939e9a7
commit e7eb7c96ba
3 changed files with 71 additions and 26 deletions

View File

@@ -10,7 +10,7 @@ load_dotenv()
TOKEN = os.getenv("HEY_GEN_TOKEN")
# POST TO CREATE VIDEO
CREATE_VIDEO_URL = 'https://api.heygen.com/v1/video.generate'
CREATE_VIDEO_URL = 'https://api.heygen.com/v1/template.generate'
GET_VIDEO_URL = 'https://api.heygen.com/v1/video_status.get'
POST_HEADER = {
'X-Api-Key': TOKEN,
@@ -20,26 +20,29 @@ GET_HEADER = {
'X-Api-Key': TOKEN
}
MATTHEW_NOAH = "11b234e504e44bfda9bc6b7aac3c8f81"
VERA_CERISE = "9bf2f27009cd403ab4ba4e22629b27bb"
EDWARD_TONY = "d3333e37952946059b45efc8482a2b6c"
TANYA_MOLLY = "07c75076b3f94df4ac658c6de72be83a"
KAYLA_ABBI = "d688099f8db9472cb4890b0561e81793"
JEROME_RYAN = "ad41feb2a5c4483085525e3d8907f512"
TYLER_CHRISTOPHER = "03c796f8ed274bb38f19e893bcbc6121"
def create_video(text):
# POST TO CREATE VIDEO
data = {
"background": "#ffffff",
"clips": [
"template_id": MATTHEW_NOAH,
"title": "video_title",
"test": False,
"variables": [
{
"avatar_id": "Mido-lite-20221128",
"avatar_style": "normal",
"input_text": text,
"offset": {
"x": 0,
"y": 0
"properties": {
"text": text
},
"scale": 1,
"voice_id": "ccb30e87c6b34ca8941f88352c71612d"
"name": "avatar_0"
}
],
"ratio": "16:9",
"test": True,
"version": "v1alpha"
]
}
response = requests.post(CREATE_VIDEO_URL, headers=POST_HEADER, json=data)
print(response.status_code)
@@ -84,4 +87,4 @@ def create_video(text):
return output_filename
else:
print(f"Failed to download file. Status code: {response.status_code}")
return None
return None