Replace Talking Photo In Template
In this guide, you'll learn how to replace photars (virtual character) with custom text and voice within a template video. You can view the example template video here.
Retrieve Template Variables
You can fetch the template variables using the following API call:
curl -X GET 'https://api.heygen.com/v1/template.get?video_id=<video_id>' \
-H 'X-Api-Key: <your-api-key>'
{
"code": 100,
"data": {
"scenes": [
{
"variables": [
{
"name": "photar_0",
"properties": [
{
"default": "e369e7deb3294abb88e4618ff319d47e",
"name": "id"
},
{
"default": "Welcome to the new era of video creation with HeyGen! Simply type your script to get started!",
"name": "text"
},
{
"default": "6d9be61f6e0646f4b6750d3eb03b118f",
"name": "voice_id"
}
],
"type": "photar"
}
]
}
],
"template_id": "617ef3f64a8d440cbdabffd6f9d82634",
"video_id": "617ef3f64a8d440cbdabffd6f9d82634"
},
"message": "Success"
}
Customize Template Variables and Generate Video
Now, you can proceed to replace the photar's id
, text
and voice_id
variables in your template. Use the following API request:
curl --request POST \
--url https://api.heygen.com/v1/template.generate \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <your-api-key>' \
--data '
{
"template_id": "617ef3f64a8d440cbdabffd6f9d82634",
"title": "video_title",
"variables": [
{
"properties": {
"id": "aaf2533a92bc48ea82cd744e072f6e1e",
"text": "HeyGen api支持更换photar了",
"voice_id": "118e0e91a87a4e60a1353a438b3601ac"
},
"name": "photar_0"
}
],
"test": false
}'
View the Result
Let's take a look at how a template video can be transformed. Below, you'll find the original template video and the video after customizing it.
Here's the original template video:
And here's the video after customizing it, where we've replaced the photar (virtual character) with custom text and voice within the template:
As you can see, with HeyGen's API, you can seamlessly replace photar content within templates, offering endless possibilities for customization and personalization.
Updated 21 days ago