diff --git a/apps/frontend/src/components/third-parties/providers/heygen.provider.tsx b/apps/frontend/src/components/third-parties/providers/heygen.provider.tsx
index c092fcfa..40112b6a 100644
--- a/apps/frontend/src/components/third-parties/providers/heygen.provider.tsx
+++ b/apps/frontend/src/components/third-parties/providers/heygen.provider.tsx
@@ -85,7 +85,9 @@ const SelectVoiceComponent: FC<{
: 'bg-third'
)}
>
-
{p.name}
+
+ {p.name}
+
{p.language}
))}
@@ -109,6 +111,7 @@ const HeygenProviderComponent = () => {
aspect_ratio: '',
captions: '',
selectedVoice: '',
+ type: '',
},
mode: 'all',
resolver: zodResolver(
@@ -205,7 +208,15 @@ const HeygenProviderComponent = () => {
avatar_name: p.avatar_name || p.name,
preview_image_url: p.preview_image_url || p.image_url,
}))}
- onChange={(id: string) => form.setValue('avatar', id)}
+ onChange={(id: string) => {
+ form.setValue('avatar', id);
+ form.setValue(
+ 'type',
+ data?.find((p: any) => p.id === id || p.avatar_id === id)?.id
+ ? 'talking_photo'
+ : 'avatar'
+ );
+ }}
/>
{form?.formState?.errors?.avatar?.message || ''}
diff --git a/libraries/nestjs-libraries/src/3rdparties/heygen/heygen.provider.ts b/libraries/nestjs-libraries/src/3rdparties/heygen/heygen.provider.ts
index 593df310..8fc248c3 100644
--- a/libraries/nestjs-libraries/src/3rdparties/heygen/heygen.provider.ts
+++ b/libraries/nestjs-libraries/src/3rdparties/heygen/heygen.provider.ts
@@ -116,19 +116,31 @@ export class HeygenProvider extends ThirdPartyAbstract<{
aspect_ratio: string;
captions: string;
selectedVoice: string;
+ type: 'talking_photo' | 'avatar';
}
): Promise {
- const {data: {video_id}} = await (
+ const {
+ data: { video_id },
+ } = await (
await fetch(`https://api.heygen.com/v2/video/generate`, {
method: 'POST',
body: JSON.stringify({
caption: data.captions === 'yes',
video_inputs: [
{
- character: {
- type: 'avatar',
- avatar_id: data.avatar,
- },
+ ...(data.type === 'avatar'
+ ? {
+ character: {
+ type: 'avatar',
+ avatar_id: data.avatar,
+ },
+ }
+ : {
+ character: {
+ type: 'talking_photo',
+ talking_photo_id: data.avatar,
+ },
+ }),
voice: {
type: 'text',
input_text: data.voice,
@@ -156,13 +168,20 @@ export class HeygenProvider extends ThirdPartyAbstract<{
).json();
while (true) {
- const {data: {status, video_url}} = await (await fetch(`https://api.heygen.com/v1/video_status.get?video_id=${video_id}`, {
- headers: {
- accept: 'application/json',
- 'content-type': 'application/json',
- 'x-api-key': apiKey,
- },
- })).json();
+ const {
+ data: { status, video_url },
+ } = await (
+ await fetch(
+ `https://api.heygen.com/v1/video_status.get?video_id=${video_id}`,
+ {
+ headers: {
+ accept: 'application/json',
+ 'content-type': 'application/json',
+ 'x-api-key': apiKey,
+ },
+ }
+ )
+ ).json();
if (status === 'completed') {
return video_url;