qt-human 2.2.0-alpha.5 → 2.2.0-alpha.6
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/dist/assets/earth_bg.png +0 -0
- package/dist/assets/empty.wav +0 -0
- package/dist/assets/images/earth_bg.png +0 -0
- package/dist/assets/images/sky.png +0 -0
- package/dist/assets/images/starflake1.png +0 -0
- package/dist/assets/images/starflake2.png +0 -0
- package/dist/assets/sky.png +0 -0
- package/dist/assets/starflake1.png +0 -0
- package/dist/assets/starflake2.png +0 -0
- package/dist/assets/wav/empty.wav +0 -0
- package/dist/bundle.esm.js +4 -0
- package/dist/bundle.iife.js +4 -0
- package/dist/bundle.umd.js +4 -0
- package/dist/index.d.ts +1031 -0
- package/dist/types/api/helper/index.d.ts +2 -0
- package/dist/types/api/human.d.ts +20 -0
- package/dist/types/api/interface/index.d.ts +35 -0
- package/dist/types/const.d.ts +12 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/modules/components/loading.d.ts +37 -0
- package/dist/types/modules/core/audio.d.ts +27 -0
- package/dist/types/modules/core/loader.d.ts +8 -0
- package/dist/types/modules/core/recorder.d.ts +26 -0
- package/dist/types/modules/core/recorder2.d.ts +38 -0
- package/dist/types/modules/core/render.d.ts +117 -0
- package/dist/types/modules/core/voice-interaction.d.ts +46 -0
- package/dist/types/modules/core/websocket.d.ts +19 -0
- package/dist/types/modules/human.d.ts +78 -0
- package/dist/types/types/api.d.ts +0 -0
- package/dist/types/types/common.d.ts +0 -0
- package/dist/types/types/declarations.d.ts +4 -0
- package/dist/types/types/enum.d.ts +20 -0
- package/dist/types/types/enum.ts +38 -0
- package/dist/types/types/index.d.ts +659 -0
- package/dist/types/types/model.d.ts +521 -0
- package/dist/types/types/recorder.d.ts +3 -0
- package/dist/types/utils/AudioManager.d.ts +45 -0
- package/dist/types/utils/actionNotifier.d.ts +11 -0
- package/dist/types/utils/aes.d.ts +3 -0
- package/dist/types/utils/blendShapes.d.ts +12 -0
- package/dist/types/utils/blendShapes2.d.ts +13 -0
- package/dist/types/utils/blendShapesAzure.d.ts +13 -0
- package/dist/types/utils/blendShapesOvr.d.ts +11 -0
- package/dist/types/utils/chatMessageHandler.d.ts +21 -0
- package/dist/types/utils/detector.d.ts +2 -0
- package/dist/types/utils/eventBus.d.ts +8 -0
- package/dist/types/utils/fileCache.d.ts +11 -0
- package/dist/types/utils/framePlayer.d.ts +28 -0
- package/dist/types/utils/frameProbeTime.d.ts +16 -0
- package/dist/types/utils/fuse.d.ts +8 -0
- package/dist/types/utils/http.d.ts +18 -0
- package/dist/types/utils/index.d.ts +8 -0
- package/dist/types/utils/repeat.d.ts +18 -0
- package/dist/types/utils/sentences.d.ts +5 -0
- package/dist/types/utils/sequence.d.ts +15 -0
- package/dist/types/utils/storage.d.ts +18 -0
- package/package.json +1 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { SSE } from 'sse.js';
|
|
2
|
+
import { QuanTe } from '@/types';
|
|
3
|
+
import { IResultData } from './interface';
|
|
4
|
+
import { CancelTokenSource } from 'axios';
|
|
5
|
+
export declare const abortAll: () => void;
|
|
6
|
+
export declare const fetchFloat32Array: (url?: string, params?: {}, isMulti?: boolean) => Promise<Float32Array>;
|
|
7
|
+
export type Text2SpeechParams = {
|
|
8
|
+
role?: string;
|
|
9
|
+
speed?: number;
|
|
10
|
+
sn?: number;
|
|
11
|
+
model?: 'paddle2' | 'paddle' | 'azure';
|
|
12
|
+
viseme?: 'a2f' | 'azure' | 'none' | 'qt' | 'ovr';
|
|
13
|
+
smooth_method?: number;
|
|
14
|
+
smooth_interations?: number;
|
|
15
|
+
};
|
|
16
|
+
export declare const getCharacterInfoApi: (id: string) => Promise<IResultData<QuanTe.API.CharacterInfo>>;
|
|
17
|
+
export declare const apiAsk: (characterId: string, params: QuanTe.API.ChatMessageParams, callback?: (res: IResultData<QuanTe.API.ChatMessage>) => void) => Promise<void>;
|
|
18
|
+
export declare const apiText2Speech: (characterId: string, params: QuanTe.API.Text2SpeechParams) => Promise<IResultData<QuanTe.API.Text2Speech>>;
|
|
19
|
+
export declare const getFetchSource: () => (AbortController | CancelTokenSource | SSE)[];
|
|
20
|
+
export declare const getGatewayTokenApi: () => Promise<IResultData<string>>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export interface IResult {
|
|
2
|
+
code: number;
|
|
3
|
+
msg: string;
|
|
4
|
+
}
|
|
5
|
+
export interface IResultData<T = any> extends IResult {
|
|
6
|
+
data: T;
|
|
7
|
+
}
|
|
8
|
+
export interface IPage<T = any> {
|
|
9
|
+
current: number;
|
|
10
|
+
limit: number;
|
|
11
|
+
totalPage: number;
|
|
12
|
+
total: number;
|
|
13
|
+
rows: T[];
|
|
14
|
+
param?: {
|
|
15
|
+
[key: string]: any;
|
|
16
|
+
} | string;
|
|
17
|
+
}
|
|
18
|
+
export interface IPageQuery {
|
|
19
|
+
page: number;
|
|
20
|
+
limit: number;
|
|
21
|
+
}
|
|
22
|
+
export interface IResultAny {
|
|
23
|
+
code: number;
|
|
24
|
+
msg: string;
|
|
25
|
+
[key: string]: any;
|
|
26
|
+
}
|
|
27
|
+
export type SystemBoolean = 'T' | 'F';
|
|
28
|
+
export type Status = 'enable' | 'disable';
|
|
29
|
+
export type ChatPermission = 'all_team_members' | 'only_me' | 'partial_members';
|
|
30
|
+
export type ChatIndexingTechnique = 'high_quality' | 'economy';
|
|
31
|
+
export type ChatDataSourceType = 'upload_file' | null;
|
|
32
|
+
export type ChatIndexingStatus = 'waiting' | 'complete' | 'indexing';
|
|
33
|
+
export type ChatDisplayStatus = 'disabled' | 'available' | 'indexing' | 'error';
|
|
34
|
+
export type ClientStatus = 'enable' | 'unenable';
|
|
35
|
+
export type GrantType = 'password' | 'sms' | 'email' | 'serectkey';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const AUTH_TOKEN_KEY = "auth-token";
|
|
2
|
+
export declare const WSS_URL = "wss-url";
|
|
3
|
+
export declare const PLATFORM_BASE_API = "platform-base-api";
|
|
4
|
+
export declare const GATEWAY_TOKEN = "apigateway-token";
|
|
5
|
+
export declare const APPID = "appid";
|
|
6
|
+
export declare const BLANDSHAPES = "blocksShapes";
|
|
7
|
+
export declare const AUDIO_URLS = "audioUrls";
|
|
8
|
+
export declare const SEARCH_TEXT = "searchText";
|
|
9
|
+
export declare const ASK_RESPONSE = "askResponse";
|
|
10
|
+
export declare const API_GATEWAY_BASE_URL = "API_GATEWAY_BASE_URL";
|
|
11
|
+
export declare const API_GPT_BASE_URL = "API_GPT_BASE_URL";
|
|
12
|
+
export declare const API_FACEGOOD_BASE_URL = "API_FACEGOOD_BASE_URL";
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import Human from '../human';
|
|
3
|
+
import { QuanTe } from '@/types';
|
|
4
|
+
declare class Loading {
|
|
5
|
+
hm: Human;
|
|
6
|
+
animationFrameId: number;
|
|
7
|
+
container: HTMLElement;
|
|
8
|
+
scene: THREE.Scene;
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
depth: number;
|
|
12
|
+
zAxisNumber: number;
|
|
13
|
+
camera: THREE.PerspectiveCamera;
|
|
14
|
+
renderer: THREE.WebGLRenderer;
|
|
15
|
+
sphere: any;
|
|
16
|
+
parameters: any[];
|
|
17
|
+
materials: any[];
|
|
18
|
+
particles_init_postion: number;
|
|
19
|
+
zprogress: number;
|
|
20
|
+
zprogress_second: number;
|
|
21
|
+
particles_first: any[];
|
|
22
|
+
particles_second: any[];
|
|
23
|
+
constructor(container: string | HTMLElement, hm: Human);
|
|
24
|
+
initProgressBar(): void;
|
|
25
|
+
initScene(): void;
|
|
26
|
+
initCamera(): void;
|
|
27
|
+
initRenderer(): void;
|
|
28
|
+
initOrbitControls(): void;
|
|
29
|
+
animate(): void;
|
|
30
|
+
initLight(): void;
|
|
31
|
+
renderSphereRotate(): void;
|
|
32
|
+
initSceneStar(initZpostion: number): THREE.Points<THREE.BufferGeometry<THREE.NormalBufferAttributes>, any, THREE.Object3DEventMap>[];
|
|
33
|
+
renderStarMove(): void;
|
|
34
|
+
onProgress({ code, progress, total }: QuanTe.Loader.Progress): void;
|
|
35
|
+
destroy(): void;
|
|
36
|
+
}
|
|
37
|
+
export default Loading;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import Emittery from 'emittery';
|
|
2
|
+
declare class QtAudio extends Emittery {
|
|
3
|
+
private url;
|
|
4
|
+
private audio;
|
|
5
|
+
static VOLUMN: number;
|
|
6
|
+
static MUTED: boolean;
|
|
7
|
+
constructor(url?: string);
|
|
8
|
+
setUrl(url: string): Promise<boolean>;
|
|
9
|
+
getUrl(): string;
|
|
10
|
+
play(): Promise<boolean>;
|
|
11
|
+
restart(): Promise<boolean>;
|
|
12
|
+
pause(): void;
|
|
13
|
+
seek(time: number): void;
|
|
14
|
+
load(): void;
|
|
15
|
+
reset(): void;
|
|
16
|
+
isLoaded(): boolean;
|
|
17
|
+
isPlaying(): boolean;
|
|
18
|
+
getDuration(): number;
|
|
19
|
+
setVolume(volume: number): void;
|
|
20
|
+
getVolume(): number;
|
|
21
|
+
destroy(): void;
|
|
22
|
+
mute(isMute?: boolean): void;
|
|
23
|
+
}
|
|
24
|
+
declare const MutilAudio: typeof QtAudio;
|
|
25
|
+
declare const _default: QtAudio;
|
|
26
|
+
export default _default;
|
|
27
|
+
export { type QtAudio, MutilAudio };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import 'blob-polyfill';
|
|
2
|
+
import type { QuanTe } from "@/types";
|
|
3
|
+
declare const loadBundleFile: (params: {
|
|
4
|
+
model: QuanTe.API.CharacterModel;
|
|
5
|
+
onProgress: (url: string, progress: number, total: number) => void;
|
|
6
|
+
}) => Promise<QuanTe.Loader.LoaderResponse>;
|
|
7
|
+
declare const loadModel: (models: QuanTe.API.CharacterModel[], onProgress?: (d: number) => void) => Promise<QuanTe.Loader.LoaderResponse[]>;
|
|
8
|
+
export { loadModel, loadBundleFile };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import Recorder from 'recorder-core';
|
|
2
|
+
import 'recorder-core/src/engine/pcm.js';
|
|
3
|
+
import QtWebSocket from './websocket';
|
|
4
|
+
import Emittery from 'emittery';
|
|
5
|
+
import type { QuanTe } from '@/types/index';
|
|
6
|
+
declare class QtRecorder extends Emittery {
|
|
7
|
+
recorder: typeof Recorder;
|
|
8
|
+
socket: QtWebSocket | null;
|
|
9
|
+
private audioBuffer;
|
|
10
|
+
Recorder: any;
|
|
11
|
+
private mediaStream;
|
|
12
|
+
private firstRequestPermision;
|
|
13
|
+
constructor();
|
|
14
|
+
start(token?: string): Promise<QuanTe.Result<QuanTe.Recorder.PermissionResult>>;
|
|
15
|
+
stop(): Promise<QuanTe.Result<null>>;
|
|
16
|
+
closeRecording(): Promise<any>;
|
|
17
|
+
requestRecorderPermission(): Promise<QuanTe.Result<QuanTe.Recorder.PermissionResult>>;
|
|
18
|
+
isOpen(): any;
|
|
19
|
+
resume(): void;
|
|
20
|
+
private connectSocket;
|
|
21
|
+
private onProcess;
|
|
22
|
+
open(): Promise<QuanTe.Result<QuanTe.Recorder.PermissionResult>>;
|
|
23
|
+
close(): Promise<QuanTe.Result<null>>;
|
|
24
|
+
destroy(): void;
|
|
25
|
+
}
|
|
26
|
+
export default QtRecorder;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import Recorder from 'recorder-core';
|
|
2
|
+
import 'recorder-core/src/engine/pcm.js';
|
|
3
|
+
import QtWebSocket from './websocket';
|
|
4
|
+
import Emittery from 'emittery';
|
|
5
|
+
import type { QuanTe } from '@/types/index';
|
|
6
|
+
declare class QtRecorder extends Emittery {
|
|
7
|
+
recorder: typeof Recorder;
|
|
8
|
+
socket: QtWebSocket | null;
|
|
9
|
+
private audioBuffer;
|
|
10
|
+
Recorder: any;
|
|
11
|
+
private firstRequestPermision;
|
|
12
|
+
private isSending;
|
|
13
|
+
private timeout;
|
|
14
|
+
private config;
|
|
15
|
+
private readonly BUFFER_SIZE;
|
|
16
|
+
private receiveTimeout;
|
|
17
|
+
private waitTime;
|
|
18
|
+
constructor(config: {
|
|
19
|
+
token: string;
|
|
20
|
+
level: number;
|
|
21
|
+
waitTime?: number;
|
|
22
|
+
});
|
|
23
|
+
start(): void;
|
|
24
|
+
stop(): void;
|
|
25
|
+
closeRecording(): Promise<boolean>;
|
|
26
|
+
requestRecorderPermission(): Promise<QuanTe.Result<QuanTe.Recorder.PermissionResult>>;
|
|
27
|
+
isOpen(): any;
|
|
28
|
+
resume(): void;
|
|
29
|
+
private connectSocket;
|
|
30
|
+
private onProcess;
|
|
31
|
+
computeAudioEnergy(audioData: Int16Array): number;
|
|
32
|
+
addAudioBuffer(buffer: Int16Array): void;
|
|
33
|
+
dealAudioData(level: number, threshold?: number): void;
|
|
34
|
+
checkAudioActivityByRMS(int16Array: Int16Array, threshold?: number): boolean;
|
|
35
|
+
openRecording(): Promise<QuanTe.Result<QuanTe.Recorder.PermissionResult>>;
|
|
36
|
+
sendMessage(buffer: Int16Array): void;
|
|
37
|
+
}
|
|
38
|
+
export default QtRecorder;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
|
|
3
|
+
import { GLTFLoader, GLTF } from 'three/examples/jsm/loaders/GLTFLoader.js';
|
|
4
|
+
import { KTX2Loader } from 'three/examples/jsm/loaders/KTX2Loader.js';
|
|
5
|
+
import Emittery from 'emittery';
|
|
6
|
+
import type { QuanTe } from '@/types/index';
|
|
7
|
+
type ActionObjType = {
|
|
8
|
+
action: THREE.AnimationAction;
|
|
9
|
+
name: string;
|
|
10
|
+
code: string;
|
|
11
|
+
animation: THREE.AnimationClip;
|
|
12
|
+
type: string;
|
|
13
|
+
text: string;
|
|
14
|
+
};
|
|
15
|
+
type BodyObject = {
|
|
16
|
+
[key: string]: QuanTe.Model.BodyOption & {
|
|
17
|
+
mesh: THREE.Mesh | undefined;
|
|
18
|
+
morphTargetInfluences?: number[] | null | undefined;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
declare class ThreeJSApp extends Emittery {
|
|
22
|
+
animationFrameId: number;
|
|
23
|
+
container: HTMLElement | null;
|
|
24
|
+
scene: THREE.Scene | null;
|
|
25
|
+
camera: THREE.PerspectiveCamera | null;
|
|
26
|
+
renderer: THREE.WebGLRenderer | null;
|
|
27
|
+
loader: GLTFLoader | null;
|
|
28
|
+
ktx2Loader: KTX2Loader | null;
|
|
29
|
+
controls: OrbitControls | null;
|
|
30
|
+
width: number;
|
|
31
|
+
height: number;
|
|
32
|
+
depth: number;
|
|
33
|
+
config: QuanTe.Model.Description;
|
|
34
|
+
model: {
|
|
35
|
+
[key: string]: GLTF;
|
|
36
|
+
};
|
|
37
|
+
mixer: THREE.AnimationMixer | null;
|
|
38
|
+
animations: {
|
|
39
|
+
code: string;
|
|
40
|
+
type: string;
|
|
41
|
+
animation: THREE.AnimationClip;
|
|
42
|
+
text: string;
|
|
43
|
+
}[];
|
|
44
|
+
actions: ActionObjType[];
|
|
45
|
+
isNotRender: boolean;
|
|
46
|
+
animationMixer: THREE.AnimationMixer | null;
|
|
47
|
+
clock: THREE.Clock | null;
|
|
48
|
+
body: BodyObject;
|
|
49
|
+
characterGroup: THREE.Group | null;
|
|
50
|
+
lightGroup: THREE.Group | null;
|
|
51
|
+
state: {
|
|
52
|
+
[key: string]: any;
|
|
53
|
+
};
|
|
54
|
+
private onWindowResizeBound;
|
|
55
|
+
private onAnimationFinishedBound;
|
|
56
|
+
private actionDefalutMap;
|
|
57
|
+
animationGroup: THREE.AnimationObjectGroup;
|
|
58
|
+
rotationCenter: THREE.Vector3;
|
|
59
|
+
private muteActionState;
|
|
60
|
+
private actionNotifier;
|
|
61
|
+
private _container;
|
|
62
|
+
constructor(container: (string | HTMLElement) | undefined, config: QuanTe.Model.Description);
|
|
63
|
+
init(): void;
|
|
64
|
+
setContainer(): void;
|
|
65
|
+
updateLight(): void;
|
|
66
|
+
initLight(): void;
|
|
67
|
+
degree2Euler(xyz: QuanTe.Model.XYZ): QuanTe.Model.XYZ;
|
|
68
|
+
private dataToMatrix4;
|
|
69
|
+
setLight(light: QuanTe.Model.Light): void;
|
|
70
|
+
setAngleView({ camera }: {
|
|
71
|
+
camera: QuanTe.Model.TCamera & {
|
|
72
|
+
duration?: number;
|
|
73
|
+
};
|
|
74
|
+
}): void;
|
|
75
|
+
gsapContainer(opts: {
|
|
76
|
+
attr?: {
|
|
77
|
+
[key: string]: any;
|
|
78
|
+
};
|
|
79
|
+
}): Promise<unknown>;
|
|
80
|
+
initOrbitControls(): void;
|
|
81
|
+
setBackground(bg?: string): void;
|
|
82
|
+
loadGLBModel(glbURL: string): void;
|
|
83
|
+
loadLowResTexture(url: string): Promise<unknown>;
|
|
84
|
+
private cloneTrack;
|
|
85
|
+
changeBundle(record: QuanTe.Loader.LoaderResponse): void;
|
|
86
|
+
loadBundles(list: QuanTe.Loader.LoaderResponse[], onProgress: (progress: number) => void): Promise<boolean>;
|
|
87
|
+
private animationFinished;
|
|
88
|
+
onWindowResize: import("lodash").DebouncedFuncLeading<() => void>;
|
|
89
|
+
setCamera(options: QuanTe.Model.TCamera): void;
|
|
90
|
+
animate(): void;
|
|
91
|
+
startRender(): void;
|
|
92
|
+
stopRender(): void;
|
|
93
|
+
gsapMorph(target: number[], source: number[], t2: any): void;
|
|
94
|
+
initIdle: import("lodash").DebouncedFunc<() => void>;
|
|
95
|
+
playAction: import("lodash").DebouncedFuncLeading<(code: string, opts?: QuanTe.PlayActionOptions) => void>;
|
|
96
|
+
stopAllActionExcludeIdle(): void;
|
|
97
|
+
stopAllAction(): void;
|
|
98
|
+
private updateControls;
|
|
99
|
+
private mousedown;
|
|
100
|
+
private mouseup;
|
|
101
|
+
private mousemove;
|
|
102
|
+
private registerListeners;
|
|
103
|
+
cleanMaterial(material: any): void;
|
|
104
|
+
destroy(): void;
|
|
105
|
+
playByShapes(shapes?: number[], idx?: number): Promise<void>;
|
|
106
|
+
addModel(code: string, modelUrl: string): void;
|
|
107
|
+
destoryModel(code: string): void;
|
|
108
|
+
muteAction(isMute?: boolean): void;
|
|
109
|
+
getModelInfo(): QuanTe.ModelInfo;
|
|
110
|
+
loadGlb(url: string, onProgress?: (event: ProgressEvent) => void): Promise<GLTF>;
|
|
111
|
+
addGlb(url: string, onProgress?: (event: ProgressEvent) => void): Promise<GLTF>;
|
|
112
|
+
setCharacterCenter(): void;
|
|
113
|
+
setVideoBackground(videoURL: string): void;
|
|
114
|
+
loadCubeBackground(imageURLs: string[]): void;
|
|
115
|
+
setBackgroundColorOrGradient(colorOrGradient: string): void;
|
|
116
|
+
}
|
|
117
|
+
export default ThreeJSApp;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import Emittery from 'emittery';
|
|
2
|
+
import QtRecorder from './recorder2';
|
|
3
|
+
export declare enum VoiceState {
|
|
4
|
+
SLEEP = "SLEEP",
|
|
5
|
+
LISTENING = "LISTENING",
|
|
6
|
+
RECORDING = "RECORDING",
|
|
7
|
+
PROCESSING = "PROCESSING",
|
|
8
|
+
SPEAKING = "SPEAKING"
|
|
9
|
+
}
|
|
10
|
+
declare class VoiceInteraction extends Emittery {
|
|
11
|
+
private isInitialized;
|
|
12
|
+
recorder?: QtRecorder;
|
|
13
|
+
private wakeFuse?;
|
|
14
|
+
private exitFuse?;
|
|
15
|
+
private interruptFuse?;
|
|
16
|
+
private config;
|
|
17
|
+
private currentState;
|
|
18
|
+
private isWake;
|
|
19
|
+
private lastRecordTime;
|
|
20
|
+
private EXIT_TIME;
|
|
21
|
+
private taskInterval?;
|
|
22
|
+
private onAnyEvent;
|
|
23
|
+
private keepActive;
|
|
24
|
+
constructor();
|
|
25
|
+
initialize(config: {
|
|
26
|
+
asrEndpoint: string;
|
|
27
|
+
wakeWords: string[];
|
|
28
|
+
exitWords: string[];
|
|
29
|
+
interruptWorlds: string[];
|
|
30
|
+
sampleRate: number;
|
|
31
|
+
gatewayToken: string;
|
|
32
|
+
level: number;
|
|
33
|
+
exitTime: number;
|
|
34
|
+
keepActive: boolean;
|
|
35
|
+
waitTime?: number;
|
|
36
|
+
}): Promise<void>;
|
|
37
|
+
private wakeWordDetection;
|
|
38
|
+
private exitWordDetection;
|
|
39
|
+
private interruptWordDetection;
|
|
40
|
+
private onWakeDetected;
|
|
41
|
+
private onSleepDetected;
|
|
42
|
+
private onInterruptDetected;
|
|
43
|
+
destroy(): void;
|
|
44
|
+
}
|
|
45
|
+
declare const _default: VoiceInteraction;
|
|
46
|
+
export default _default;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
declare class QtWebSocket {
|
|
2
|
+
private url;
|
|
3
|
+
private ws;
|
|
4
|
+
private callback;
|
|
5
|
+
private isDestroyed;
|
|
6
|
+
constructor(url: string);
|
|
7
|
+
connect(config?: {
|
|
8
|
+
onopen?: () => void;
|
|
9
|
+
onerror?: (e: any) => void;
|
|
10
|
+
onclose?: (e: any) => void;
|
|
11
|
+
onmessage?: () => void;
|
|
12
|
+
}): Promise<void>;
|
|
13
|
+
send(data: any): Promise<void>;
|
|
14
|
+
close(): void;
|
|
15
|
+
onMessage(callback: (data: any) => void): void;
|
|
16
|
+
isReady(): boolean;
|
|
17
|
+
destroy(): void;
|
|
18
|
+
}
|
|
19
|
+
export default QtWebSocket;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import Emittery from 'emittery';
|
|
2
|
+
import ThreeJSApp from './core/render';
|
|
3
|
+
import Loading from './components/loading';
|
|
4
|
+
import Recorder from './core/recorder';
|
|
5
|
+
import type { QuanTe } from '@/types/index';
|
|
6
|
+
import { IResultData } from '@/api/interface';
|
|
7
|
+
import voiceInteraction from './core/voice-interaction';
|
|
8
|
+
declare class Human extends Emittery implements QuanTe.Human {
|
|
9
|
+
name: string;
|
|
10
|
+
core: ThreeJSApp | null;
|
|
11
|
+
private config;
|
|
12
|
+
loading?: Loading;
|
|
13
|
+
private audio;
|
|
14
|
+
private container;
|
|
15
|
+
recorder: Recorder | null;
|
|
16
|
+
private voiceCallback;
|
|
17
|
+
private status;
|
|
18
|
+
private probeTimeout;
|
|
19
|
+
private callbackTimeout;
|
|
20
|
+
private mutilAudios;
|
|
21
|
+
private exeSequence;
|
|
22
|
+
private fetchSequence;
|
|
23
|
+
private openRecorderTimeout;
|
|
24
|
+
private onAnyEvent;
|
|
25
|
+
private characterData;
|
|
26
|
+
private isNotRender;
|
|
27
|
+
private mode;
|
|
28
|
+
private ttsclient;
|
|
29
|
+
private framePlayer;
|
|
30
|
+
voiceInter: typeof voiceInteraction;
|
|
31
|
+
constructor(config: QuanTe.Configuration);
|
|
32
|
+
private refreshGatewayToken;
|
|
33
|
+
private initTTSClient;
|
|
34
|
+
setCharacterData(characterId: string): Promise<boolean>;
|
|
35
|
+
setCharacter(characterId: string, configuration?: Partial<QuanTe.Configuration>): Promise<boolean>;
|
|
36
|
+
speak(text: string, callback?: Function, opt?: {
|
|
37
|
+
[key: string]: any;
|
|
38
|
+
}): Promise<QuanTe.API.StreamAudioPlayInfo>;
|
|
39
|
+
private _speak;
|
|
40
|
+
askCommand(params: QuanTe.API.AskParams, callback: (msgs: IResultData<string[]>) => void): Promise<void>;
|
|
41
|
+
ask(params: QuanTe.API.AskParams, callback: (msgs: IResultData<QuanTe.API.ChatMessage[]>) => void): Promise<QuanTe.Result<QuanTe.API.AskResponse>>;
|
|
42
|
+
private _textToSpeech;
|
|
43
|
+
askStream(params: QuanTe.API.AskParams, callback: (msgs: IResultData<QuanTe.API.ChatMessage[]>) => void): Promise<QuanTe.Result<QuanTe.API.AskStreamResponse>>;
|
|
44
|
+
private initBlendShapes;
|
|
45
|
+
private probeTimePlay;
|
|
46
|
+
speakByAudioShapes(uris: string[], shapes: Array<number[][]>): Promise<boolean>;
|
|
47
|
+
speakByAudioStreamShapes(audios: ArrayBuffer[], shapes: number[][], rate?: number): Promise<boolean>;
|
|
48
|
+
private createAudio;
|
|
49
|
+
speakByAudio(uri: string, shapes: number[][]): Promise<boolean>;
|
|
50
|
+
private setRecorderStatus;
|
|
51
|
+
private play;
|
|
52
|
+
startVoice2Text(callback?: (data: QuanTe.Recorder.Voice2Text) => void): Promise<QuanTe.API.IResultData<QuanTe.Recorder.PermissionResult>>;
|
|
53
|
+
stopVoice2Text(callback?: (data: QuanTe.Recorder.Voice2Text) => void): Promise<QuanTe.Result<null>>;
|
|
54
|
+
stop(): Promise<boolean>;
|
|
55
|
+
getStatus(): QuanTe.Status;
|
|
56
|
+
private initStorage;
|
|
57
|
+
muteAudio(isMute?: boolean): void;
|
|
58
|
+
muteAction(isMute?: boolean): void;
|
|
59
|
+
private dealVoice2Text;
|
|
60
|
+
destroy(): Promise<void>;
|
|
61
|
+
updateToken(token: string): void;
|
|
62
|
+
setAngleView({ camera }: {
|
|
63
|
+
camera: QuanTe.Model.TCamera & {
|
|
64
|
+
duration?: number;
|
|
65
|
+
};
|
|
66
|
+
}): void;
|
|
67
|
+
playAction(code: string, opts?: QuanTe.PlayActionOptions): Promise<void>;
|
|
68
|
+
getModelInfo(): QuanTe.ModelInfo | null;
|
|
69
|
+
openVoiceInteraction(config: QuanTe.VoiceConfig): Promise<boolean>;
|
|
70
|
+
private voiceInteractionEmit;
|
|
71
|
+
offlineRender(files: QuanTe.API.CharacterModel[]): Promise<boolean>;
|
|
72
|
+
startRender(): Promise<boolean>;
|
|
73
|
+
stopRender(): Promise<boolean>;
|
|
74
|
+
closeRecorder(): Promise<boolean>;
|
|
75
|
+
openRecorder(): Promise<QuanTe.Result<QuanTe.Recorder.PermissionResult>>;
|
|
76
|
+
}
|
|
77
|
+
export default Human;
|
|
78
|
+
export type { QuanTe };
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare enum EmitEvent {
|
|
2
|
+
HUMAN_READY = "human.ready",
|
|
3
|
+
HUMAN_ERROR = "human.error",
|
|
4
|
+
HUMAN_ACTION_PENDING = "human.action.pending",
|
|
5
|
+
HUMAN_LOAD_PROGRESS = "human.load.progress",
|
|
6
|
+
CORE_BUNDLES_LOADED = "core.bundles.loaded",
|
|
7
|
+
RECORDER_MESSAGE = "recorder.message",
|
|
8
|
+
RECORDER_START = "recorder.start",
|
|
9
|
+
RECORDER_STOP = "recorder.stop",
|
|
10
|
+
RECORDER_SENDING = "recorder.sending",
|
|
11
|
+
VOICE_SLEEP = "voice.sleep",
|
|
12
|
+
VOICE_WAKE = "voice.wake",
|
|
13
|
+
VOICE_INTERRUPT = "voice.interrupt",
|
|
14
|
+
VOICE2TEXT = "voice2text",
|
|
15
|
+
ASRTEXT = "asrtext",
|
|
16
|
+
WAKE_RECORDER_START = "wake.record.start",
|
|
17
|
+
WAKE_RECORDER_STOP = "wake.record.stop",
|
|
18
|
+
AUDIO_PAUSE = "audio.pause",
|
|
19
|
+
AUDIO_PLAY = "audio.play"
|
|
20
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export enum EmitEvent {
|
|
2
|
+
// human对象加载完成
|
|
3
|
+
HUMAN_READY = 'human.ready',
|
|
4
|
+
// 错误
|
|
5
|
+
HUMAN_ERROR = 'human.error',
|
|
6
|
+
// 触发指令
|
|
7
|
+
HUMAN_ACTION_PENDING = 'human.action.pending',
|
|
8
|
+
// 加载进度
|
|
9
|
+
HUMAN_LOAD_PROGRESS = 'human.load.progress',
|
|
10
|
+
// 模型加载完成
|
|
11
|
+
CORE_BUNDLES_LOADED = 'core.bundles.loaded',
|
|
12
|
+
// 录音消息
|
|
13
|
+
RECORDER_MESSAGE = 'recorder.message',
|
|
14
|
+
// 录音开始
|
|
15
|
+
RECORDER_START = 'recorder.start',
|
|
16
|
+
// 录音结束
|
|
17
|
+
RECORDER_STOP = 'recorder.stop',
|
|
18
|
+
// 发送录音数据(ASR)
|
|
19
|
+
RECORDER_SENDING = 'recorder.sending',
|
|
20
|
+
// 语音-睡眠模式
|
|
21
|
+
VOICE_SLEEP = 'voice.sleep',
|
|
22
|
+
// 语音-唤醒模式
|
|
23
|
+
VOICE_WAKE = 'voice.wake',
|
|
24
|
+
// 语音-打断
|
|
25
|
+
VOICE_INTERRUPT = 'voice.interrupt',
|
|
26
|
+
// 语音转文本
|
|
27
|
+
VOICE2TEXT = 'voice2text',
|
|
28
|
+
// asr文本数据
|
|
29
|
+
ASRTEXT = 'asrtext',
|
|
30
|
+
// 唤醒状态下开始录音
|
|
31
|
+
WAKE_RECORDER_START = 'wake.record.start',
|
|
32
|
+
// 唤醒状态下结束录音
|
|
33
|
+
WAKE_RECORDER_STOP = 'wake.record.stop',
|
|
34
|
+
// 音频暂停播放
|
|
35
|
+
AUDIO_PAUSE = 'audio.pause',
|
|
36
|
+
// 播放音频
|
|
37
|
+
AUDIO_PLAY = 'audio.play',
|
|
38
|
+
}
|