@memberjunction/ai-heygen 2.43.0 → 2.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +16 -0
- package/package.json +3 -3
- package/readme.md +273 -61
package/.turbo/turbo-build.log
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @memberjunction/ai-heygen
|
|
2
2
|
|
|
3
|
+
## 2.45.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [21d456d]
|
|
8
|
+
- @memberjunction/ai@2.45.0
|
|
9
|
+
- @memberjunction/global@2.45.0
|
|
10
|
+
|
|
11
|
+
## 2.44.0
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [fbc30dc]
|
|
16
|
+
- @memberjunction/ai@2.44.0
|
|
17
|
+
- @memberjunction/global@2.44.0
|
|
18
|
+
|
|
3
19
|
## 2.43.0
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/ai-heygen",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.45.0",
|
|
4
4
|
"description": "MemberJunction Wrapper for HeyGen Video Generation",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"typescript": "^5.4.5"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@memberjunction/ai": "2.
|
|
19
|
-
"@memberjunction/global": "2.
|
|
18
|
+
"@memberjunction/ai": "2.45.0",
|
|
19
|
+
"@memberjunction/global": "2.45.0",
|
|
20
20
|
"elevenlabs": "^1.51.0"
|
|
21
21
|
}
|
|
22
22
|
}
|
package/readme.md
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
# @memberjunction/ai-heygen
|
|
2
2
|
|
|
3
|
-
A
|
|
3
|
+
A MemberJunction provider package that wraps HeyGen's video generation API, enabling AI-powered avatar video creation within the MemberJunction AI framework. This package implements the BaseVideoGenerator abstract class to provide standardized video generation capabilities.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The HeyGen provider enables you to:
|
|
8
|
+
- Generate videos with AI-powered digital avatars
|
|
9
|
+
- Retrieve and manage available avatar options
|
|
10
|
+
- Customize video output with backgrounds, dimensions, and positioning
|
|
11
|
+
- Integrate seamlessly with MemberJunction's AI architecture
|
|
4
12
|
|
|
5
13
|
## Features
|
|
6
14
|
|
|
7
|
-
- **Avatar Video Generation**: Create videos with AI-powered digital avatars
|
|
8
|
-
- **Avatar Management**: Retrieve and
|
|
9
|
-
- **Custom Backgrounds**: Set custom background images for
|
|
10
|
-
- **Audio Integration**:
|
|
15
|
+
- **Avatar Video Generation**: Create videos with AI-powered digital avatars speaking custom audio
|
|
16
|
+
- **Avatar Management**: Retrieve and browse available avatar options with preview assets
|
|
17
|
+
- **Custom Backgrounds**: Set custom background images for professional video outputs
|
|
18
|
+
- **Audio Integration**: Sync avatar speech with pre-generated audio assets
|
|
11
19
|
- **Video Customization**: Control output dimensions, avatar scaling, and positioning
|
|
12
|
-
- **Standardized Interface**:
|
|
20
|
+
- **Standardized Interface**: Implements MemberJunction's BaseVideoGenerator abstract class for consistent API usage
|
|
21
|
+
- **Type-Safe Implementation**: Full TypeScript support with proper typing throughout
|
|
13
22
|
|
|
14
23
|
## Installation
|
|
15
24
|
|
|
@@ -19,13 +28,24 @@ npm install @memberjunction/ai-heygen
|
|
|
19
28
|
|
|
20
29
|
## Requirements
|
|
21
30
|
|
|
22
|
-
- Node.js 16
|
|
23
|
-
-
|
|
24
|
-
-
|
|
31
|
+
- Node.js 16 or higher
|
|
32
|
+
- TypeScript 5.4.5 or higher
|
|
33
|
+
- A valid HeyGen API key (obtain from [HeyGen Dashboard](https://app.heygen.com/))
|
|
34
|
+
- MemberJunction Core dependencies:
|
|
35
|
+
- `@memberjunction/ai` (same version)
|
|
36
|
+
- `@memberjunction/global` (same version)
|
|
37
|
+
|
|
38
|
+
## Configuration
|
|
39
|
+
|
|
40
|
+
Before using the HeyGen provider, ensure you have:
|
|
41
|
+
|
|
42
|
+
1. A valid HeyGen API key from your [HeyGen account](https://app.heygen.com/)
|
|
43
|
+
2. Pre-uploaded audio and image assets in your HeyGen account (these will provide you with asset IDs)
|
|
44
|
+
3. Selected an avatar ID from the available options
|
|
25
45
|
|
|
26
46
|
## Usage
|
|
27
47
|
|
|
28
|
-
###
|
|
48
|
+
### Basic Setup
|
|
29
49
|
|
|
30
50
|
```typescript
|
|
31
51
|
import { HeyGenVideoGenerator } from '@memberjunction/ai-heygen';
|
|
@@ -34,9 +54,9 @@ import { HeyGenVideoGenerator } from '@memberjunction/ai-heygen';
|
|
|
34
54
|
const heyGen = new HeyGenVideoGenerator('your-heygen-api-key');
|
|
35
55
|
```
|
|
36
56
|
|
|
37
|
-
###
|
|
57
|
+
### Retrieve Available Avatars
|
|
38
58
|
|
|
39
|
-
|
|
59
|
+
Before creating videos, explore the available avatars:
|
|
40
60
|
|
|
41
61
|
```typescript
|
|
42
62
|
const avatars = await heyGen.GetAvatars();
|
|
@@ -49,39 +69,98 @@ avatars.forEach(avatar => {
|
|
|
49
69
|
console.log(`Preview Video: ${avatar.previewVideoUrl}`);
|
|
50
70
|
console.log('---');
|
|
51
71
|
});
|
|
72
|
+
|
|
73
|
+
// Find a specific avatar by name
|
|
74
|
+
const femaleAvatar = avatars.find(a => a.gender === 'female' && a.name.includes('Professional'));
|
|
52
75
|
```
|
|
53
76
|
|
|
54
77
|
### Create an Avatar Video
|
|
55
78
|
|
|
56
|
-
Generate a video with an avatar speaking:
|
|
79
|
+
Generate a video with an avatar speaking your content:
|
|
57
80
|
|
|
58
81
|
```typescript
|
|
59
|
-
import { AvatarVideoParams } from '@memberjunction/ai';
|
|
82
|
+
import { AvatarVideoParams, VideoResult } from '@memberjunction/ai';
|
|
60
83
|
|
|
61
84
|
// Configure video parameters
|
|
62
85
|
const videoParams: AvatarVideoParams = {
|
|
63
|
-
avatarId: 'avatar-id-from-getavatars',
|
|
64
|
-
audioAssetId: 'your-audio-asset-id',
|
|
65
|
-
imageAssetId: 'your-background-image-id',
|
|
66
|
-
outputWidth: 1280,
|
|
67
|
-
outputHeight: 720,
|
|
68
|
-
scale: 1.0,
|
|
69
|
-
avatarStyle: 'normal',
|
|
70
|
-
offsetX: 0,
|
|
71
|
-
offsetY: 0
|
|
86
|
+
avatarId: 'avatar-id-from-getavatars', // Use an ID from GetAvatars()
|
|
87
|
+
audioAssetId: 'your-audio-asset-id', // Pre-uploaded audio asset ID from HeyGen
|
|
88
|
+
imageAssetId: 'your-background-image-id', // Pre-uploaded background image ID
|
|
89
|
+
outputWidth: 1280, // Video width in pixels
|
|
90
|
+
outputHeight: 720, // Video height in pixels
|
|
91
|
+
scale: 1.0, // Avatar scale (1.0 = 100%)
|
|
92
|
+
avatarStyle: 'normal', // Avatar presentation style
|
|
93
|
+
offsetX: 0, // Horizontal position offset
|
|
94
|
+
offsetY: 0 // Vertical position offset
|
|
72
95
|
};
|
|
73
96
|
|
|
74
97
|
// Generate the video
|
|
75
|
-
const result = await heyGen.CreateAvatarVideo(videoParams);
|
|
98
|
+
const result: VideoResult = await heyGen.CreateAvatarVideo(videoParams);
|
|
76
99
|
|
|
77
100
|
if (result.success) {
|
|
78
101
|
console.log('Video generation successful!');
|
|
79
102
|
console.log('Video ID:', result.videoId);
|
|
103
|
+
// The video ID can be used to check status or download via HeyGen's API
|
|
80
104
|
} else {
|
|
81
105
|
console.error('Error generating video:', result.errorMessage);
|
|
82
106
|
}
|
|
83
107
|
```
|
|
84
108
|
|
|
109
|
+
### Complete Example
|
|
110
|
+
|
|
111
|
+
Here's a complete example that demonstrates the full workflow:
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
import { HeyGenVideoGenerator } from '@memberjunction/ai-heygen';
|
|
115
|
+
import { AvatarVideoParams, VideoResult } from '@memberjunction/ai';
|
|
116
|
+
|
|
117
|
+
async function createProfessionalVideo() {
|
|
118
|
+
try {
|
|
119
|
+
// Initialize the HeyGen client
|
|
120
|
+
const heyGen = new HeyGenVideoGenerator(process.env.HEYGEN_API_KEY);
|
|
121
|
+
|
|
122
|
+
// Get available avatars
|
|
123
|
+
const avatars = await heyGen.GetAvatars();
|
|
124
|
+
console.log(`Found ${avatars.length} available avatars`);
|
|
125
|
+
|
|
126
|
+
// Select the first professional avatar
|
|
127
|
+
const professionalAvatar = avatars.find(a =>
|
|
128
|
+
a.name.toLowerCase().includes('professional')
|
|
129
|
+
) || avatars[0];
|
|
130
|
+
|
|
131
|
+
console.log(`Using avatar: ${professionalAvatar.name}`);
|
|
132
|
+
|
|
133
|
+
// Create video with the selected avatar
|
|
134
|
+
const videoParams: AvatarVideoParams = {
|
|
135
|
+
avatarId: professionalAvatar.id,
|
|
136
|
+
audioAssetId: 'audio_asset_123', // Your pre-uploaded audio
|
|
137
|
+
imageAssetId: 'image_asset_456', // Your pre-uploaded background
|
|
138
|
+
outputWidth: 1920,
|
|
139
|
+
outputHeight: 1080,
|
|
140
|
+
scale: 1.2, // Slightly larger avatar
|
|
141
|
+
avatarStyle: 'normal',
|
|
142
|
+
offsetX: 100, // Move avatar 100px to the right
|
|
143
|
+
offsetY: 0
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const result: VideoResult = await heyGen.CreateAvatarVideo(videoParams);
|
|
147
|
+
|
|
148
|
+
if (result.success) {
|
|
149
|
+
console.log(`Video created successfully! ID: ${result.videoId}`);
|
|
150
|
+
// Use the video ID to check status or download the video
|
|
151
|
+
} else {
|
|
152
|
+
console.error(`Failed to create video: ${result.errorMessage}`);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
} catch (error) {
|
|
156
|
+
console.error('Unexpected error:', error);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// Run the example
|
|
161
|
+
createProfessionalVideo();
|
|
162
|
+
```
|
|
163
|
+
|
|
85
164
|
### Check Supported Methods
|
|
86
165
|
|
|
87
166
|
Check which methods are supported by the current implementation:
|
|
@@ -95,68 +174,201 @@ console.log('Supported methods:', supportedMethods);
|
|
|
95
174
|
|
|
96
175
|
### HeyGenVideoGenerator Class
|
|
97
176
|
|
|
98
|
-
|
|
177
|
+
The main class that extends `BaseVideoGenerator` to provide HeyGen-specific video generation functionality. This class is registered with MemberJunction's global class registry using the `@RegisterClass` decorator.
|
|
99
178
|
|
|
100
179
|
#### Constructor
|
|
101
180
|
|
|
102
181
|
```typescript
|
|
103
|
-
|
|
182
|
+
constructor(apiKey: string)
|
|
104
183
|
```
|
|
105
184
|
|
|
185
|
+
**Parameters:**
|
|
186
|
+
- `apiKey` - Your HeyGen API key for authentication
|
|
187
|
+
|
|
106
188
|
#### Methods
|
|
107
189
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
190
|
+
##### `CreateAvatarVideo(params: AvatarVideoParams): Promise<VideoResult>`
|
|
191
|
+
Generates a video with an AI avatar speaking the provided audio content.
|
|
192
|
+
|
|
193
|
+
**Parameters:**
|
|
194
|
+
- `params` - Configuration object for the avatar video (see AvatarVideoParams below)
|
|
195
|
+
|
|
196
|
+
**Returns:**
|
|
197
|
+
- `Promise<VideoResult>` - Result object containing success status and video ID or error message
|
|
112
198
|
|
|
113
|
-
|
|
199
|
+
##### `GetAvatars(): Promise<AvatarInfo[]>`
|
|
200
|
+
Retrieves a list of all available avatars from HeyGen.
|
|
114
201
|
|
|
115
|
-
|
|
202
|
+
**Returns:**
|
|
203
|
+
- `Promise<AvatarInfo[]>` - Array of avatar information objects
|
|
116
204
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
- `imageAssetId`: ID of the background image
|
|
120
|
-
- `outputWidth`: Width of the output video in pixels
|
|
121
|
-
- `outputHeight`: Height of the output video in pixels
|
|
122
|
-
- `scale`: Scale factor for the avatar (1.0 = 100%)
|
|
123
|
-
- `avatarStyle`: Style of the avatar ('normal' or other available styles)
|
|
124
|
-
- `offsetX`: Horizontal position offset of the avatar
|
|
125
|
-
- `offsetY`: Vertical position offset of the avatar
|
|
205
|
+
##### `GetSupportedMethods(): Promise<string[]>`
|
|
206
|
+
Returns a list of method names supported by this implementation.
|
|
126
207
|
|
|
127
|
-
|
|
208
|
+
**Returns:**
|
|
209
|
+
- `Promise<string[]>` - Array of supported method names
|
|
128
210
|
|
|
129
|
-
|
|
211
|
+
##### `CreateVideoTranslation(params: any): Promise<VideoResult>`
|
|
212
|
+
**Note:** This method is not yet implemented and will throw an error if called.
|
|
130
213
|
|
|
131
|
-
|
|
132
|
-
- `videoId`: ID of the generated video (if successful)
|
|
133
|
-
- `errorMessage`: Error message (if unsuccessful)
|
|
214
|
+
### Type Definitions
|
|
134
215
|
|
|
135
|
-
|
|
216
|
+
#### AvatarVideoParams
|
|
217
|
+
|
|
218
|
+
Configuration parameters for creating an avatar video:
|
|
219
|
+
|
|
220
|
+
```typescript
|
|
221
|
+
interface AvatarVideoParams {
|
|
222
|
+
avatarId: string; // ID of the avatar (from GetAvatars)
|
|
223
|
+
audioAssetId: string; // ID of pre-uploaded audio asset
|
|
224
|
+
imageAssetId: string; // ID of pre-uploaded background image
|
|
225
|
+
outputWidth: number; // Video width in pixels
|
|
226
|
+
outputHeight: number; // Video height in pixels
|
|
227
|
+
scale: number; // Avatar scale factor (1.0 = 100%)
|
|
228
|
+
avatarStyle: string; // Avatar style (e.g., 'normal')
|
|
229
|
+
offsetX: number; // Horizontal position offset in pixels
|
|
230
|
+
offsetY: number; // Vertical position offset in pixels
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
#### VideoResult
|
|
235
|
+
|
|
236
|
+
Result object returned from video generation operations:
|
|
237
|
+
|
|
238
|
+
```typescript
|
|
239
|
+
interface VideoResult {
|
|
240
|
+
success: boolean; // Whether the operation succeeded
|
|
241
|
+
videoId?: string; // ID of the generated video (if successful)
|
|
242
|
+
errorMessage?: string; // Error details (if unsuccessful)
|
|
243
|
+
}
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
#### AvatarInfo
|
|
136
247
|
|
|
137
248
|
Information about an available avatar:
|
|
138
249
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
250
|
+
```typescript
|
|
251
|
+
interface AvatarInfo {
|
|
252
|
+
id: string; // Unique avatar identifier
|
|
253
|
+
name: string; // Display name of the avatar
|
|
254
|
+
gender: string; // Avatar's gender
|
|
255
|
+
previewImageUrl: string; // URL to avatar preview image
|
|
256
|
+
previewVideoUrl: string; // URL to avatar preview video
|
|
257
|
+
}
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
## Integration Details
|
|
261
|
+
|
|
262
|
+
### HeyGen API Endpoints
|
|
144
263
|
|
|
145
|
-
|
|
264
|
+
This package integrates with the following HeyGen API v2 endpoints:
|
|
146
265
|
|
|
147
|
-
|
|
266
|
+
- **Video Generation**: `https://api.heygen.com/v2/video/generate`
|
|
267
|
+
- Used by `CreateAvatarVideo()` method
|
|
268
|
+
- Requires pre-uploaded audio and image assets
|
|
269
|
+
|
|
270
|
+
- **Avatar Management**: `https://api.heygen.com/v2/avatars`
|
|
271
|
+
- Used by `GetAvatars()` method
|
|
272
|
+
- Returns available avatars with preview assets
|
|
148
273
|
|
|
149
|
-
|
|
150
|
-
- `https://api.heygen.com/v2/avatars` - For retrieving available avatars
|
|
274
|
+
### Authentication
|
|
151
275
|
|
|
152
|
-
|
|
276
|
+
All API requests use the `X-Api-Key` header for authentication. The API key is passed during class instantiation and stored securely within the instance.
|
|
277
|
+
|
|
278
|
+
### Error Handling
|
|
279
|
+
|
|
280
|
+
The package implements comprehensive error handling:
|
|
281
|
+
- Network errors are caught and logged
|
|
282
|
+
- API errors are returned in the `VideoResult.errorMessage` field
|
|
283
|
+
- All methods return predictable result objects rather than throwing exceptions
|
|
153
284
|
|
|
154
285
|
## Dependencies
|
|
155
286
|
|
|
156
|
-
|
|
157
|
-
- `@memberjunction/
|
|
158
|
-
- `
|
|
287
|
+
### Runtime Dependencies
|
|
288
|
+
- `@memberjunction/ai` - Core AI framework interfaces and base classes
|
|
289
|
+
- `@memberjunction/global` - Global utilities and class registration
|
|
290
|
+
- `axios` - HTTP client for API communication (Note: This needs to be added to package.json)
|
|
291
|
+
|
|
292
|
+
### Development Dependencies
|
|
293
|
+
- `typescript` ^5.4.5 - TypeScript compiler
|
|
294
|
+
- `ts-node-dev` ^2.0.0 - Development server with auto-reload
|
|
295
|
+
|
|
296
|
+
## Build and Development
|
|
297
|
+
|
|
298
|
+
### Building the Package
|
|
299
|
+
|
|
300
|
+
```bash
|
|
301
|
+
# From the package directory
|
|
302
|
+
npm run build
|
|
303
|
+
|
|
304
|
+
# From the repository root
|
|
305
|
+
npm run build -- --filter="@memberjunction/ai-heygen"
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
### Development Mode
|
|
309
|
+
|
|
310
|
+
```bash
|
|
311
|
+
# Run in watch mode with auto-reload
|
|
312
|
+
npm run start
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
### Package Structure
|
|
316
|
+
|
|
317
|
+
```
|
|
318
|
+
packages/AI/Providers/HeyGen/
|
|
319
|
+
├── src/
|
|
320
|
+
│ └── index.ts # Main implementation file
|
|
321
|
+
├── dist/ # Compiled JavaScript output
|
|
322
|
+
├── package.json # Package configuration
|
|
323
|
+
├── tsconfig.json # TypeScript configuration
|
|
324
|
+
├── typedoc.json # Documentation generation config
|
|
325
|
+
└── readme.md # This file
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
## Integration with MemberJunction
|
|
329
|
+
|
|
330
|
+
This package follows MemberJunction's architectural patterns:
|
|
331
|
+
|
|
332
|
+
1. **Class Registration**: Uses `@RegisterClass` decorator for automatic registration with the global class registry
|
|
333
|
+
2. **Abstract Implementation**: Extends `BaseVideoGenerator` from `@memberjunction/ai`
|
|
334
|
+
3. **Consistent API**: Follows MemberJunction's standardized patterns for AI providers
|
|
335
|
+
4. **Type Safety**: Full TypeScript implementation with proper typing
|
|
336
|
+
|
|
337
|
+
### Using with MemberJunction's AI System
|
|
338
|
+
|
|
339
|
+
The HeyGen provider can be dynamically loaded through MemberJunction's AI provider system:
|
|
340
|
+
|
|
341
|
+
```typescript
|
|
342
|
+
import { AIEngine } from '@memberjunction/ai';
|
|
343
|
+
|
|
344
|
+
// The HeyGen provider will be automatically available if installed
|
|
345
|
+
const aiEngine = new AIEngine();
|
|
346
|
+
const videoGenerator = await aiEngine.GetVideoGenerator('HeyGenVideoGenerator', apiKey);
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
## Contributing
|
|
350
|
+
|
|
351
|
+
When contributing to this package:
|
|
352
|
+
|
|
353
|
+
1. Follow the MemberJunction code style guide
|
|
354
|
+
2. Ensure all TypeScript compiles without errors
|
|
355
|
+
3. Update this README if adding new features
|
|
356
|
+
4. Add appropriate error handling for all API calls
|
|
357
|
+
5. Maintain backward compatibility
|
|
358
|
+
|
|
359
|
+
## Known Limitations
|
|
360
|
+
|
|
361
|
+
1. `CreateVideoTranslation()` is not yet implemented
|
|
362
|
+
2. Requires pre-uploaded assets (audio and images) in HeyGen
|
|
363
|
+
3. No webhook support for video completion notifications
|
|
364
|
+
4. The package.json is missing the `axios` dependency (needs to be added)
|
|
365
|
+
|
|
366
|
+
## Additional Resources
|
|
367
|
+
|
|
368
|
+
- [HeyGen API Documentation](https://docs.heygen.com/)
|
|
369
|
+
- [HeyGen Dashboard](https://app.heygen.com/)
|
|
370
|
+
- [MemberJunction AI Documentation](https://docs.memberjunction.org/ai)
|
|
159
371
|
|
|
160
372
|
## License
|
|
161
373
|
|
|
162
|
-
ISC
|
|
374
|
+
ISC - See LICENSE file in the repository root for details.
|