@digipair/skill-heygen 0.89.0 → 0.91.0-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/.swcrc +28 -0
- package/README.md +7 -0
- package/eslint.config.mjs +22 -0
- package/package.json +23 -7
- package/rollup.config.cjs +28 -0
- package/src/lib/skill-heygen.spec.ts +7 -0
- package/src/lib/skill-heygen.ts +150 -0
- package/tsconfig.json +13 -0
- package/tsconfig.lib.json +19 -0
- package/index.cjs.d.ts +0 -1
- package/index.cjs.js +0 -134
- package/index.esm.js +0 -126
- package/libs/skill-heygen/src/lib/skill-heygen.d.ts +0 -6
- /package/{index.d.ts → src/index.d.ts} +0 -0
- /package/{libs/skill-heygen/src/index.d.ts → src/index.ts} +0 -0
- /package/{schema.fr.json → src/schema.fr.json} +0 -0
- /package/{schema.json → src/schema.json} +0 -0
package/.swcrc
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"jsc": {
|
|
3
|
+
"target": "es2017",
|
|
4
|
+
"parser": {
|
|
5
|
+
"syntax": "typescript",
|
|
6
|
+
"decorators": true,
|
|
7
|
+
"dynamicImport": true
|
|
8
|
+
},
|
|
9
|
+
"transform": {
|
|
10
|
+
"decoratorMetadata": true,
|
|
11
|
+
"legacyDecorator": true
|
|
12
|
+
},
|
|
13
|
+
"keepClassNames": true,
|
|
14
|
+
"externalHelpers": true,
|
|
15
|
+
"loose": true
|
|
16
|
+
},
|
|
17
|
+
"module": {
|
|
18
|
+
"type": "es6"
|
|
19
|
+
},
|
|
20
|
+
"sourceMaps": true,
|
|
21
|
+
"exclude": [
|
|
22
|
+
"jest.config.ts",
|
|
23
|
+
".*\\.spec.tsx?$",
|
|
24
|
+
".*\\.test.tsx?$",
|
|
25
|
+
"./src/jest-setup.ts$",
|
|
26
|
+
"./**/jest-setup.ts$"
|
|
27
|
+
]
|
|
28
|
+
}
|
package/README.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import baseConfig from '../../eslint.config.mjs';
|
|
2
|
+
|
|
3
|
+
export default [
|
|
4
|
+
...baseConfig,
|
|
5
|
+
{
|
|
6
|
+
files: ['**/*.json'],
|
|
7
|
+
rules: {
|
|
8
|
+
'@nx/dependency-checks': [
|
|
9
|
+
'error',
|
|
10
|
+
{
|
|
11
|
+
ignoredFiles: [
|
|
12
|
+
'{projectRoot}/eslint.config.{js,cjs,mjs}',
|
|
13
|
+
'{projectRoot}/rollup.config.{js,ts,mjs,mts,cjs,cts}',
|
|
14
|
+
],
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
languageOptions: {
|
|
19
|
+
parser: await import('jsonc-eslint-parser'),
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
];
|
package/package.json
CHANGED
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digipair/skill-heygen",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.91.0-0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "dist/libs/skill-heygen/index.cjs.js",
|
|
6
|
+
"module": "dist/libs/skill-heygen/index.esm.js",
|
|
7
|
+
"types": "dist/libs/skill-heygen/index.esm.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
"./package.json": "./libs/skill-heygen/package.json",
|
|
10
|
+
".": {
|
|
11
|
+
"development": "./dist/libs/skill-heygen/src/index.ts",
|
|
12
|
+
"types": "./dist/libs/skill-heygen/index.esm.d.ts",
|
|
13
|
+
"import": "./dist/libs/skill-heygen/index.esm.js",
|
|
14
|
+
"default": "./dist/libs/skill-heygen/index.cjs.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
4
17
|
"keywords": [
|
|
5
18
|
"digipair",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
19
|
+
"web",
|
|
20
|
+
"service"
|
|
8
21
|
],
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
22
|
+
"nx": {
|
|
23
|
+
"name": "skill-heygen"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@digipair/engine": "0.91.0-0"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const { withNx } = require('@nx/rollup/with-nx');
|
|
2
|
+
|
|
3
|
+
module.exports = withNx(
|
|
4
|
+
{
|
|
5
|
+
main: 'libs/skill-heygen/src/index.ts',
|
|
6
|
+
outputPath: 'dist/libs/skill-heygen',
|
|
7
|
+
tsConfig: 'libs/skill-heygen/tsconfig.lib.json',
|
|
8
|
+
compiler: 'swc',
|
|
9
|
+
format: ['esm', "cjs"],
|
|
10
|
+
assets: [
|
|
11
|
+
{
|
|
12
|
+
input: 'libs/skill-heygen/',
|
|
13
|
+
glob: 'package.json',
|
|
14
|
+
output: '.'
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
input: 'libs/skill-heygen/src/',
|
|
18
|
+
glob: '*.json',
|
|
19
|
+
output: '.'
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
// Provide additional rollup configuration here. See: https://rollupjs.org/configuration-options
|
|
25
|
+
// e.g.
|
|
26
|
+
// output: { sourcemap: true },
|
|
27
|
+
}
|
|
28
|
+
);
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
+
import { PinsSettings } from '@digipair/engine';
|
|
3
|
+
|
|
4
|
+
class HeygenService {
|
|
5
|
+
async newSession(params: any, _pinsSettingsList: PinsSettings[], context: any): Promise<any> {
|
|
6
|
+
const {
|
|
7
|
+
serverUrl = context.privates.HEYGEN_SERVER_URL ?? process.env['HEYGEN_SERVER_URL'],
|
|
8
|
+
apiKey = context.privates.HEYGEN_API_KEY ?? process.env['HEYGEN_API_KEY'],
|
|
9
|
+
quality = 'low',
|
|
10
|
+
avatar = '',
|
|
11
|
+
voice = '',
|
|
12
|
+
} = params;
|
|
13
|
+
|
|
14
|
+
const response = await fetch(`${serverUrl}/v1/streaming.new`, {
|
|
15
|
+
signal: context.protected?.signal,
|
|
16
|
+
method: 'POST',
|
|
17
|
+
headers: {
|
|
18
|
+
'Content-Type': 'application/json',
|
|
19
|
+
'X-Api-Key': apiKey,
|
|
20
|
+
},
|
|
21
|
+
body: JSON.stringify({
|
|
22
|
+
quality,
|
|
23
|
+
avatar_name: avatar,
|
|
24
|
+
voice: {
|
|
25
|
+
voice_id: voice,
|
|
26
|
+
},
|
|
27
|
+
}),
|
|
28
|
+
});
|
|
29
|
+
if (response.status === 500) {
|
|
30
|
+
throw new Error('Server error');
|
|
31
|
+
} else {
|
|
32
|
+
const data = await response.json();
|
|
33
|
+
return data.data;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async handleICE(params: any, _pinsSettingsList: PinsSettings[], context: any): Promise<any> {
|
|
38
|
+
const {
|
|
39
|
+
serverUrl = context.privates.HEYGEN_SERVER_URL ?? process.env['HEYGEN_SERVER_URL'],
|
|
40
|
+
apiKey = context.privates.HEYGEN_API_KEY ?? process.env['HEYGEN_API_KEY'],
|
|
41
|
+
sessionId,
|
|
42
|
+
candidate,
|
|
43
|
+
} = params;
|
|
44
|
+
|
|
45
|
+
const response = await fetch(`${serverUrl}/v1/streaming.ice`, {
|
|
46
|
+
signal: context.protected?.signal,
|
|
47
|
+
method: 'POST',
|
|
48
|
+
headers: {
|
|
49
|
+
'Content-Type': 'application/json',
|
|
50
|
+
'X-Api-Key': apiKey,
|
|
51
|
+
},
|
|
52
|
+
body: JSON.stringify({ session_id: sessionId, candidate }),
|
|
53
|
+
});
|
|
54
|
+
if (response.status === 500) {
|
|
55
|
+
throw new Error('Server error');
|
|
56
|
+
} else {
|
|
57
|
+
const data = await response.json();
|
|
58
|
+
return data;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async startSession(params: any, _pinsSettingsList: PinsSettings[], context: any): Promise<any> {
|
|
63
|
+
const {
|
|
64
|
+
serverUrl = context.privates.HEYGEN_SERVER_URL ?? process.env['HEYGEN_SERVER_URL'],
|
|
65
|
+
apiKey = context.privates.HEYGEN_API_KEY ?? process.env['HEYGEN_API_KEY'],
|
|
66
|
+
sessionId,
|
|
67
|
+
sdp,
|
|
68
|
+
} = params;
|
|
69
|
+
|
|
70
|
+
const response = await fetch(`${serverUrl}/v1/streaming.start`, {
|
|
71
|
+
signal: context.protected?.signal,
|
|
72
|
+
method: 'POST',
|
|
73
|
+
headers: {
|
|
74
|
+
'Content-Type': 'application/json',
|
|
75
|
+
'X-Api-Key': apiKey,
|
|
76
|
+
},
|
|
77
|
+
body: JSON.stringify({ session_id: sessionId, sdp }),
|
|
78
|
+
});
|
|
79
|
+
if (response.status === 500) {
|
|
80
|
+
throw new Error('Server error');
|
|
81
|
+
} else {
|
|
82
|
+
const data = await response.json();
|
|
83
|
+
return data.data;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async talk(params: any, _pinsSettingsList: PinsSettings[], context: any): Promise<any> {
|
|
88
|
+
const {
|
|
89
|
+
serverUrl = context.privates.HEYGEN_SERVER_URL ?? process.env['HEYGEN_SERVER_URL'],
|
|
90
|
+
apiKey = context.privates.HEYGEN_API_KEY ?? process.env['HEYGEN_API_KEY'],
|
|
91
|
+
sessionId,
|
|
92
|
+
text,
|
|
93
|
+
} = params;
|
|
94
|
+
|
|
95
|
+
const response = await fetch(`${serverUrl}/v1/streaming.task`, {
|
|
96
|
+
signal: context.protected?.signal,
|
|
97
|
+
method: 'POST',
|
|
98
|
+
headers: {
|
|
99
|
+
'Content-Type': 'application/json',
|
|
100
|
+
'X-Api-Key': apiKey,
|
|
101
|
+
},
|
|
102
|
+
body: JSON.stringify({ session_id: sessionId, text }),
|
|
103
|
+
});
|
|
104
|
+
if (response.status === 500) {
|
|
105
|
+
throw new Error('Server error');
|
|
106
|
+
} else {
|
|
107
|
+
const data = await response.json();
|
|
108
|
+
return data.data;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async stop(params: any, _pinsSettingsList: PinsSettings[], context: any): Promise<any> {
|
|
113
|
+
const {
|
|
114
|
+
serverUrl = context.privates.HEYGEN_SERVER_URL ?? process.env['HEYGEN_SERVER_URL'],
|
|
115
|
+
apiKey = context.privates.HEYGEN_API_KEY ?? process.env['HEYGEN_API_KEY'],
|
|
116
|
+
sessionId,
|
|
117
|
+
} = params;
|
|
118
|
+
|
|
119
|
+
const response = await fetch(`${serverUrl}/v1/streaming.stop`, {
|
|
120
|
+
signal: context.protected?.signal,
|
|
121
|
+
method: 'POST',
|
|
122
|
+
headers: {
|
|
123
|
+
'Content-Type': 'application/json',
|
|
124
|
+
'X-Api-Key': apiKey,
|
|
125
|
+
},
|
|
126
|
+
body: JSON.stringify({ session_id: sessionId }),
|
|
127
|
+
});
|
|
128
|
+
if (response.status === 500) {
|
|
129
|
+
throw new Error('Server error');
|
|
130
|
+
} else {
|
|
131
|
+
const data = await response.json();
|
|
132
|
+
return data.data;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export const newSession = (params: any, pinsSettingsList: PinsSettings[], context: any) =>
|
|
138
|
+
new HeygenService().newSession(params, pinsSettingsList, context);
|
|
139
|
+
|
|
140
|
+
export const handleICE = (params: any, pinsSettingsList: PinsSettings[], context: any) =>
|
|
141
|
+
new HeygenService().handleICE(params, pinsSettingsList, context);
|
|
142
|
+
|
|
143
|
+
export const startSession = (params: any, pinsSettingsList: PinsSettings[], context: any) =>
|
|
144
|
+
new HeygenService().startSession(params, pinsSettingsList, context);
|
|
145
|
+
|
|
146
|
+
export const talk = (params: any, pinsSettingsList: PinsSettings[], context: any) =>
|
|
147
|
+
new HeygenService().talk(params, pinsSettingsList, context);
|
|
148
|
+
|
|
149
|
+
export const stop = (params: any, pinsSettingsList: PinsSettings[], context: any) =>
|
|
150
|
+
new HeygenService().stop(params, pinsSettingsList, context);
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"rootDir": "src",
|
|
5
|
+
"outDir": "dist",
|
|
6
|
+
"tsBuildInfoFile": "dist/tsconfig.lib.tsbuildinfo",
|
|
7
|
+
"emitDeclarationOnly": true,
|
|
8
|
+
"module": "esnext",
|
|
9
|
+
"moduleResolution": "node",
|
|
10
|
+
"forceConsistentCasingInFileNames": true,
|
|
11
|
+
"types": ["node"]
|
|
12
|
+
},
|
|
13
|
+
"include": ["src/**/*.ts"],
|
|
14
|
+
"references": [
|
|
15
|
+
{
|
|
16
|
+
"path": "../engine/tsconfig.lib.json"
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
}
|
package/index.cjs.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./src/index";
|
package/index.cjs.js
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */ let HeygenService = class HeygenService {
|
|
6
|
-
async newSession(params, _pinsSettingsList, context) {
|
|
7
|
-
var _context_protected;
|
|
8
|
-
var _context_privates_HEYGEN_SERVER_URL, _context_privates_HEYGEN_API_KEY;
|
|
9
|
-
const { serverUrl = (_context_privates_HEYGEN_SERVER_URL = context.privates.HEYGEN_SERVER_URL) != null ? _context_privates_HEYGEN_SERVER_URL : process.env['HEYGEN_SERVER_URL'], apiKey = (_context_privates_HEYGEN_API_KEY = context.privates.HEYGEN_API_KEY) != null ? _context_privates_HEYGEN_API_KEY : process.env['HEYGEN_API_KEY'], quality = 'low', avatar = '', voice = '' } = params;
|
|
10
|
-
const response = await fetch(`${serverUrl}/v1/streaming.new`, {
|
|
11
|
-
signal: (_context_protected = context.protected) == null ? void 0 : _context_protected.signal,
|
|
12
|
-
method: 'POST',
|
|
13
|
-
headers: {
|
|
14
|
-
'Content-Type': 'application/json',
|
|
15
|
-
'X-Api-Key': apiKey
|
|
16
|
-
},
|
|
17
|
-
body: JSON.stringify({
|
|
18
|
-
quality,
|
|
19
|
-
avatar_name: avatar,
|
|
20
|
-
voice: {
|
|
21
|
-
voice_id: voice
|
|
22
|
-
}
|
|
23
|
-
})
|
|
24
|
-
});
|
|
25
|
-
if (response.status === 500) {
|
|
26
|
-
throw new Error('Server error');
|
|
27
|
-
} else {
|
|
28
|
-
const data = await response.json();
|
|
29
|
-
return data.data;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
async handleICE(params, _pinsSettingsList, context) {
|
|
33
|
-
var _context_protected;
|
|
34
|
-
var _context_privates_HEYGEN_SERVER_URL, _context_privates_HEYGEN_API_KEY;
|
|
35
|
-
const { serverUrl = (_context_privates_HEYGEN_SERVER_URL = context.privates.HEYGEN_SERVER_URL) != null ? _context_privates_HEYGEN_SERVER_URL : process.env['HEYGEN_SERVER_URL'], apiKey = (_context_privates_HEYGEN_API_KEY = context.privates.HEYGEN_API_KEY) != null ? _context_privates_HEYGEN_API_KEY : process.env['HEYGEN_API_KEY'], sessionId, candidate } = params;
|
|
36
|
-
const response = await fetch(`${serverUrl}/v1/streaming.ice`, {
|
|
37
|
-
signal: (_context_protected = context.protected) == null ? void 0 : _context_protected.signal,
|
|
38
|
-
method: 'POST',
|
|
39
|
-
headers: {
|
|
40
|
-
'Content-Type': 'application/json',
|
|
41
|
-
'X-Api-Key': apiKey
|
|
42
|
-
},
|
|
43
|
-
body: JSON.stringify({
|
|
44
|
-
session_id: sessionId,
|
|
45
|
-
candidate
|
|
46
|
-
})
|
|
47
|
-
});
|
|
48
|
-
if (response.status === 500) {
|
|
49
|
-
throw new Error('Server error');
|
|
50
|
-
} else {
|
|
51
|
-
const data = await response.json();
|
|
52
|
-
return data;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
async startSession(params, _pinsSettingsList, context) {
|
|
56
|
-
var _context_protected;
|
|
57
|
-
var _context_privates_HEYGEN_SERVER_URL, _context_privates_HEYGEN_API_KEY;
|
|
58
|
-
const { serverUrl = (_context_privates_HEYGEN_SERVER_URL = context.privates.HEYGEN_SERVER_URL) != null ? _context_privates_HEYGEN_SERVER_URL : process.env['HEYGEN_SERVER_URL'], apiKey = (_context_privates_HEYGEN_API_KEY = context.privates.HEYGEN_API_KEY) != null ? _context_privates_HEYGEN_API_KEY : process.env['HEYGEN_API_KEY'], sessionId, sdp } = params;
|
|
59
|
-
const response = await fetch(`${serverUrl}/v1/streaming.start`, {
|
|
60
|
-
signal: (_context_protected = context.protected) == null ? void 0 : _context_protected.signal,
|
|
61
|
-
method: 'POST',
|
|
62
|
-
headers: {
|
|
63
|
-
'Content-Type': 'application/json',
|
|
64
|
-
'X-Api-Key': apiKey
|
|
65
|
-
},
|
|
66
|
-
body: JSON.stringify({
|
|
67
|
-
session_id: sessionId,
|
|
68
|
-
sdp
|
|
69
|
-
})
|
|
70
|
-
});
|
|
71
|
-
if (response.status === 500) {
|
|
72
|
-
throw new Error('Server error');
|
|
73
|
-
} else {
|
|
74
|
-
const data = await response.json();
|
|
75
|
-
return data.data;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
async talk(params, _pinsSettingsList, context) {
|
|
79
|
-
var _context_protected;
|
|
80
|
-
var _context_privates_HEYGEN_SERVER_URL, _context_privates_HEYGEN_API_KEY;
|
|
81
|
-
const { serverUrl = (_context_privates_HEYGEN_SERVER_URL = context.privates.HEYGEN_SERVER_URL) != null ? _context_privates_HEYGEN_SERVER_URL : process.env['HEYGEN_SERVER_URL'], apiKey = (_context_privates_HEYGEN_API_KEY = context.privates.HEYGEN_API_KEY) != null ? _context_privates_HEYGEN_API_KEY : process.env['HEYGEN_API_KEY'], sessionId, text } = params;
|
|
82
|
-
const response = await fetch(`${serverUrl}/v1/streaming.task`, {
|
|
83
|
-
signal: (_context_protected = context.protected) == null ? void 0 : _context_protected.signal,
|
|
84
|
-
method: 'POST',
|
|
85
|
-
headers: {
|
|
86
|
-
'Content-Type': 'application/json',
|
|
87
|
-
'X-Api-Key': apiKey
|
|
88
|
-
},
|
|
89
|
-
body: JSON.stringify({
|
|
90
|
-
session_id: sessionId,
|
|
91
|
-
text
|
|
92
|
-
})
|
|
93
|
-
});
|
|
94
|
-
if (response.status === 500) {
|
|
95
|
-
throw new Error('Server error');
|
|
96
|
-
} else {
|
|
97
|
-
const data = await response.json();
|
|
98
|
-
return data.data;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
async stop(params, _pinsSettingsList, context) {
|
|
102
|
-
var _context_protected;
|
|
103
|
-
var _context_privates_HEYGEN_SERVER_URL, _context_privates_HEYGEN_API_KEY;
|
|
104
|
-
const { serverUrl = (_context_privates_HEYGEN_SERVER_URL = context.privates.HEYGEN_SERVER_URL) != null ? _context_privates_HEYGEN_SERVER_URL : process.env['HEYGEN_SERVER_URL'], apiKey = (_context_privates_HEYGEN_API_KEY = context.privates.HEYGEN_API_KEY) != null ? _context_privates_HEYGEN_API_KEY : process.env['HEYGEN_API_KEY'], sessionId } = params;
|
|
105
|
-
const response = await fetch(`${serverUrl}/v1/streaming.stop`, {
|
|
106
|
-
signal: (_context_protected = context.protected) == null ? void 0 : _context_protected.signal,
|
|
107
|
-
method: 'POST',
|
|
108
|
-
headers: {
|
|
109
|
-
'Content-Type': 'application/json',
|
|
110
|
-
'X-Api-Key': apiKey
|
|
111
|
-
},
|
|
112
|
-
body: JSON.stringify({
|
|
113
|
-
session_id: sessionId
|
|
114
|
-
})
|
|
115
|
-
});
|
|
116
|
-
if (response.status === 500) {
|
|
117
|
-
throw new Error('Server error');
|
|
118
|
-
} else {
|
|
119
|
-
const data = await response.json();
|
|
120
|
-
return data.data;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
const newSession = (params, pinsSettingsList, context)=>new HeygenService().newSession(params, pinsSettingsList, context);
|
|
125
|
-
const handleICE = (params, pinsSettingsList, context)=>new HeygenService().handleICE(params, pinsSettingsList, context);
|
|
126
|
-
const startSession = (params, pinsSettingsList, context)=>new HeygenService().startSession(params, pinsSettingsList, context);
|
|
127
|
-
const talk = (params, pinsSettingsList, context)=>new HeygenService().talk(params, pinsSettingsList, context);
|
|
128
|
-
const stop = (params, pinsSettingsList, context)=>new HeygenService().stop(params, pinsSettingsList, context);
|
|
129
|
-
|
|
130
|
-
exports.handleICE = handleICE;
|
|
131
|
-
exports.newSession = newSession;
|
|
132
|
-
exports.startSession = startSession;
|
|
133
|
-
exports.stop = stop;
|
|
134
|
-
exports.talk = talk;
|
package/index.esm.js
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */ let HeygenService = class HeygenService {
|
|
2
|
-
async newSession(params, _pinsSettingsList, context) {
|
|
3
|
-
var _context_protected;
|
|
4
|
-
var _context_privates_HEYGEN_SERVER_URL, _context_privates_HEYGEN_API_KEY;
|
|
5
|
-
const { serverUrl = (_context_privates_HEYGEN_SERVER_URL = context.privates.HEYGEN_SERVER_URL) != null ? _context_privates_HEYGEN_SERVER_URL : process.env['HEYGEN_SERVER_URL'], apiKey = (_context_privates_HEYGEN_API_KEY = context.privates.HEYGEN_API_KEY) != null ? _context_privates_HEYGEN_API_KEY : process.env['HEYGEN_API_KEY'], quality = 'low', avatar = '', voice = '' } = params;
|
|
6
|
-
const response = await fetch(`${serverUrl}/v1/streaming.new`, {
|
|
7
|
-
signal: (_context_protected = context.protected) == null ? void 0 : _context_protected.signal,
|
|
8
|
-
method: 'POST',
|
|
9
|
-
headers: {
|
|
10
|
-
'Content-Type': 'application/json',
|
|
11
|
-
'X-Api-Key': apiKey
|
|
12
|
-
},
|
|
13
|
-
body: JSON.stringify({
|
|
14
|
-
quality,
|
|
15
|
-
avatar_name: avatar,
|
|
16
|
-
voice: {
|
|
17
|
-
voice_id: voice
|
|
18
|
-
}
|
|
19
|
-
})
|
|
20
|
-
});
|
|
21
|
-
if (response.status === 500) {
|
|
22
|
-
throw new Error('Server error');
|
|
23
|
-
} else {
|
|
24
|
-
const data = await response.json();
|
|
25
|
-
return data.data;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
async handleICE(params, _pinsSettingsList, context) {
|
|
29
|
-
var _context_protected;
|
|
30
|
-
var _context_privates_HEYGEN_SERVER_URL, _context_privates_HEYGEN_API_KEY;
|
|
31
|
-
const { serverUrl = (_context_privates_HEYGEN_SERVER_URL = context.privates.HEYGEN_SERVER_URL) != null ? _context_privates_HEYGEN_SERVER_URL : process.env['HEYGEN_SERVER_URL'], apiKey = (_context_privates_HEYGEN_API_KEY = context.privates.HEYGEN_API_KEY) != null ? _context_privates_HEYGEN_API_KEY : process.env['HEYGEN_API_KEY'], sessionId, candidate } = params;
|
|
32
|
-
const response = await fetch(`${serverUrl}/v1/streaming.ice`, {
|
|
33
|
-
signal: (_context_protected = context.protected) == null ? void 0 : _context_protected.signal,
|
|
34
|
-
method: 'POST',
|
|
35
|
-
headers: {
|
|
36
|
-
'Content-Type': 'application/json',
|
|
37
|
-
'X-Api-Key': apiKey
|
|
38
|
-
},
|
|
39
|
-
body: JSON.stringify({
|
|
40
|
-
session_id: sessionId,
|
|
41
|
-
candidate
|
|
42
|
-
})
|
|
43
|
-
});
|
|
44
|
-
if (response.status === 500) {
|
|
45
|
-
throw new Error('Server error');
|
|
46
|
-
} else {
|
|
47
|
-
const data = await response.json();
|
|
48
|
-
return data;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
async startSession(params, _pinsSettingsList, context) {
|
|
52
|
-
var _context_protected;
|
|
53
|
-
var _context_privates_HEYGEN_SERVER_URL, _context_privates_HEYGEN_API_KEY;
|
|
54
|
-
const { serverUrl = (_context_privates_HEYGEN_SERVER_URL = context.privates.HEYGEN_SERVER_URL) != null ? _context_privates_HEYGEN_SERVER_URL : process.env['HEYGEN_SERVER_URL'], apiKey = (_context_privates_HEYGEN_API_KEY = context.privates.HEYGEN_API_KEY) != null ? _context_privates_HEYGEN_API_KEY : process.env['HEYGEN_API_KEY'], sessionId, sdp } = params;
|
|
55
|
-
const response = await fetch(`${serverUrl}/v1/streaming.start`, {
|
|
56
|
-
signal: (_context_protected = context.protected) == null ? void 0 : _context_protected.signal,
|
|
57
|
-
method: 'POST',
|
|
58
|
-
headers: {
|
|
59
|
-
'Content-Type': 'application/json',
|
|
60
|
-
'X-Api-Key': apiKey
|
|
61
|
-
},
|
|
62
|
-
body: JSON.stringify({
|
|
63
|
-
session_id: sessionId,
|
|
64
|
-
sdp
|
|
65
|
-
})
|
|
66
|
-
});
|
|
67
|
-
if (response.status === 500) {
|
|
68
|
-
throw new Error('Server error');
|
|
69
|
-
} else {
|
|
70
|
-
const data = await response.json();
|
|
71
|
-
return data.data;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
async talk(params, _pinsSettingsList, context) {
|
|
75
|
-
var _context_protected;
|
|
76
|
-
var _context_privates_HEYGEN_SERVER_URL, _context_privates_HEYGEN_API_KEY;
|
|
77
|
-
const { serverUrl = (_context_privates_HEYGEN_SERVER_URL = context.privates.HEYGEN_SERVER_URL) != null ? _context_privates_HEYGEN_SERVER_URL : process.env['HEYGEN_SERVER_URL'], apiKey = (_context_privates_HEYGEN_API_KEY = context.privates.HEYGEN_API_KEY) != null ? _context_privates_HEYGEN_API_KEY : process.env['HEYGEN_API_KEY'], sessionId, text } = params;
|
|
78
|
-
const response = await fetch(`${serverUrl}/v1/streaming.task`, {
|
|
79
|
-
signal: (_context_protected = context.protected) == null ? void 0 : _context_protected.signal,
|
|
80
|
-
method: 'POST',
|
|
81
|
-
headers: {
|
|
82
|
-
'Content-Type': 'application/json',
|
|
83
|
-
'X-Api-Key': apiKey
|
|
84
|
-
},
|
|
85
|
-
body: JSON.stringify({
|
|
86
|
-
session_id: sessionId,
|
|
87
|
-
text
|
|
88
|
-
})
|
|
89
|
-
});
|
|
90
|
-
if (response.status === 500) {
|
|
91
|
-
throw new Error('Server error');
|
|
92
|
-
} else {
|
|
93
|
-
const data = await response.json();
|
|
94
|
-
return data.data;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
async stop(params, _pinsSettingsList, context) {
|
|
98
|
-
var _context_protected;
|
|
99
|
-
var _context_privates_HEYGEN_SERVER_URL, _context_privates_HEYGEN_API_KEY;
|
|
100
|
-
const { serverUrl = (_context_privates_HEYGEN_SERVER_URL = context.privates.HEYGEN_SERVER_URL) != null ? _context_privates_HEYGEN_SERVER_URL : process.env['HEYGEN_SERVER_URL'], apiKey = (_context_privates_HEYGEN_API_KEY = context.privates.HEYGEN_API_KEY) != null ? _context_privates_HEYGEN_API_KEY : process.env['HEYGEN_API_KEY'], sessionId } = params;
|
|
101
|
-
const response = await fetch(`${serverUrl}/v1/streaming.stop`, {
|
|
102
|
-
signal: (_context_protected = context.protected) == null ? void 0 : _context_protected.signal,
|
|
103
|
-
method: 'POST',
|
|
104
|
-
headers: {
|
|
105
|
-
'Content-Type': 'application/json',
|
|
106
|
-
'X-Api-Key': apiKey
|
|
107
|
-
},
|
|
108
|
-
body: JSON.stringify({
|
|
109
|
-
session_id: sessionId
|
|
110
|
-
})
|
|
111
|
-
});
|
|
112
|
-
if (response.status === 500) {
|
|
113
|
-
throw new Error('Server error');
|
|
114
|
-
} else {
|
|
115
|
-
const data = await response.json();
|
|
116
|
-
return data.data;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
const newSession = (params, pinsSettingsList, context)=>new HeygenService().newSession(params, pinsSettingsList, context);
|
|
121
|
-
const handleICE = (params, pinsSettingsList, context)=>new HeygenService().handleICE(params, pinsSettingsList, context);
|
|
122
|
-
const startSession = (params, pinsSettingsList, context)=>new HeygenService().startSession(params, pinsSettingsList, context);
|
|
123
|
-
const talk = (params, pinsSettingsList, context)=>new HeygenService().talk(params, pinsSettingsList, context);
|
|
124
|
-
const stop = (params, pinsSettingsList, context)=>new HeygenService().stop(params, pinsSettingsList, context);
|
|
125
|
-
|
|
126
|
-
export { handleICE, newSession, startSession, stop, talk };
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { PinsSettings } from '@digipair/engine';
|
|
2
|
-
export declare const newSession: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<any>;
|
|
3
|
-
export declare const handleICE: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<any>;
|
|
4
|
-
export declare const startSession: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<any>;
|
|
5
|
-
export declare const talk: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<any>;
|
|
6
|
-
export declare const stop: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<any>;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|