管理模板
本 API 指南概述了使用模板进行批量请求生成。
模板允许您添加和自定义文本、图像、视频、音频、声音和头像。 如果您想保存视频配置以供将来使用,创建模板是比直接生成视频更好的选择。 🦊
快速入门
让我们深入了解如何创建模板并列出您的模板,以便您以后可以使用它们高效地生成批量视频。
创建模板
要创建批量视频模板,请使用以下 API 请求。 它允许您定义各种设置,包括音频文本、头像和背景,以高效地生成可重复使用的视频模板。 自定义参数以满足您的需要。 创建后,您可以在创建批量请求中使用响应中的'id'作为'template_id'来使用此模板生成批量请求。您可以从 音频列表 API 获取 'audio_id' 和 'audio_service',并从 csv 列表 API 获取"csv_id"。您可以在 'audio_text' 中使用 '{{}}' 格式的宏,这些宏将由您提供的 CSV 文件中的值动态替换。例如,如果您在文本中包含 '{{First Name}}',它将被 CSV 中每个相应条目的名称(如"John"和"Smith")替换,从而为列表中的每个视频创建个性化音频。我们支持每个请求最多 20 个模板变量。请确保您的文本和 CSV 文件中这些变量的数量和名称完全匹配。模板变量名称不区分大小写。如果 CSV 中缺少任何模板变量,则会返回错误。
curl --request POST \
--url 'https://api.immersive-fox.com/v1/template/create_bulk_template/' \
--header 'X-Api-Key: <your-api-key>' \
--header 'Content-Type: application/json' \
--data { \
"csv_id": 45, \
"template_name": "My new template", \
"configurations": [ \
{ \
"audio_text": "Hi, My name is {{First Name}}", \
"avatar": 102, \
"avatar_size": 76, \
"background_color": "#ffffff", \
"background_music_is_personalized": "system", \
"background_music_volume": 0.1, \
"frame_height": 1080, \
"frame_width": 1920, \
"is_personalized_audio": false, \
"scene_number": 1, \
"scene_transition": "none", \
"audio_id": 2, \
"audio_service": "google_audio", \
"user_voice_speed": 1, \
"x_position": 0.604931, \
"y_position": 0.43101 \
} \
] \
}
{
"id": 1142,
"project_name": "My new template",
"csv_id": 45,
"user": 31,
}
使用 AI 生成模板
Immersive Fox 提供强大的功能,可自动创建模板。您无需手动设计每个模板,而是可以利用我们的 AI 模型为您生成模板。只需提供描述性文本提示,我们的算法就会制作一个包含场景、文本、背景和声音的综合模板。我们的 AI 还将在批量视频生成过程中利用指定 CSV 文件中的数据。这使您能够轻松创建针对客户量身定制的营销活动。您可以通过在有效负载中提供 optional_params_for_scripts
字段来指定视频中使用 CSV 中的哪些字段。使用以下 curl 命令请求 AI 生成的模板:
curl --request POST \
--url 'https://api.immersive-fox.com/v1/template/generate_bulk_template_with_ai/' \
--header 'X-Api-Key: <your-api-key>' \
--header 'Content-Type: application/json' \
--data { \
"avatar_gender": "female", # male / female \
"template_name": "Project_01", \
"target_audience" : "Subscribers of Spotify", \
"description" : "Tell our users that their subscription is going to finish soon", \
"main_language" : "English", \
"goal" : "Renew Subscription", \
"allow_third_party_ml_models": true, \
"length": "long", # short / medium / long \
"optional_params_for_scripts": ["person_name", "subscription_type", "subscription_charges"] \
}
{
"id": 1142,
"project_name": "Project_01",
"user": 31,
}
列出模板
要列出用户创建的所有模板,请使用以下 API 请求。它将返回所有模板的详细信息,让您可以查看和管理它们。获得模板后,您可以在 创建批量请求 中使用这些模板中的 'id' 作为 'template_id' 来使用此模板生成批量请求。
curl --request GET \
--url 'https://api.immersive-fox.com/v1/template/bulk_templates' \
--header 'X-Api-Key: <your-api-key>' \
--header 'Content-Type: application/json'
[
{
"id": 1112,
"project_name": "My old template",
"csv_id": 41,
"user": 31
},
{
"id": 1142,
"project_name": "My new template",
"csv_id": 45,
"user": 31
}
]
获取模板详细信息
要获取特定模板的详细信息,请使用以下 API 请求。它提供有关所选模板的信息,允许您在批量请求生成之前查看配置。获得模板详细信息后,您可以在 创建批量请求 中使用 'id' 作为 'template_id' 来使用此模板生成批量请求。
curl --request GET \
--url 'https://api.immersive-fox.com/v1/template/bulk_template/<template_id>' \
--header 'X-Api-Key: <your-api-key>' \
--header 'Content-Type: application/json'
{
"csv_id": 47,
"template_name": "My new template",
"configurations": [ {
"audio_text": "Hi, My name is {{First Name}}",
"avatar": 223,
"avatar_size": 75,
"background_color": "#ffffff",
"background_music_is_personalized": "system",
"background_music_volume": 0.1,
"frame_height": 1080,
"frame_width": 1920,
"is_personalized_audio": false,
"scene_number": 1,
"scene_transition": "none",
"audio_id": 2,
"audio_service": "google_audio",
"user_voice_speed": 1,
"x_position": 0.604931,
"y_position": 0.431010,
}