@prometheusavatar/core 0.1.0 → 0.3.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/README.md +102 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# @prometheusavatar/core
|
|
2
|
+
|
|
3
|
+
Give your AI agent an embodied avatar — Live2D rendering, TTS, lip-sync, and emotion analysis in one SDK.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @prometheusavatar/core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { createAvatar } from '@prometheusavatar/core';
|
|
13
|
+
|
|
14
|
+
const avatar = await createAvatar({
|
|
15
|
+
container: document.getElementById('avatar')!,
|
|
16
|
+
modelUrl: '/models/haru/haru.model3.json',
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
// Avatar speaks with auto-detected emotion + lip-sync
|
|
20
|
+
await avatar.speak('Hello! How are you today? 😊');
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## API Reference
|
|
24
|
+
|
|
25
|
+
### `createAvatar(options): Promise<PrometheusAvatar>`
|
|
26
|
+
|
|
27
|
+
Factory function to create and initialize an avatar.
|
|
28
|
+
|
|
29
|
+
| Option | Type | Default | Description |
|
|
30
|
+
|--------|------|---------|-------------|
|
|
31
|
+
| `container` | `HTMLElement` | required | DOM element to render into |
|
|
32
|
+
| `modelUrl` | `string` | required | URL to Live2D model JSON |
|
|
33
|
+
| `width` | `number` | `800` | Canvas width |
|
|
34
|
+
| `height` | `number` | `600` | Canvas height |
|
|
35
|
+
| `backgroundColor` | `number` | `0x00000000` | Canvas background (hex) |
|
|
36
|
+
| `ttsEngine` | `ITTSEngine` | `WebSpeechTTS` | Custom TTS engine |
|
|
37
|
+
| `debug` | `boolean` | `false` | Enable debug logging |
|
|
38
|
+
|
|
39
|
+
### `PrometheusAvatar`
|
|
40
|
+
|
|
41
|
+
#### Methods
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
avatar.speak(text: string): Promise<void> // Speak with auto emotion + lip-sync
|
|
45
|
+
avatar.setEmotion(emotion: Emotion): void // Manually set emotion
|
|
46
|
+
avatar.processText(text: string): EmotionResult // Process LLM stream (no TTS)
|
|
47
|
+
avatar.loadModel(modelUrl: string): Promise<void> // Switch avatar model
|
|
48
|
+
avatar.stop(): void // Stop speech + lip-sync
|
|
49
|
+
avatar.resize(width, height): void // Resize canvas
|
|
50
|
+
avatar.getEmotion(): Emotion // Get current emotion
|
|
51
|
+
avatar.destroy(): void // Cleanup resources
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
#### Events
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
avatar.on('speech:start', ({ text }) => { ... });
|
|
58
|
+
avatar.on('speech:end', ({ text }) => { ... });
|
|
59
|
+
avatar.on('emotion:change', ({ result, previous }) => { ... });
|
|
60
|
+
avatar.on('lipsync:frame', ({ frame }) => { ... });
|
|
61
|
+
avatar.on('model:loaded', ({ modelUrl }) => { ... });
|
|
62
|
+
avatar.on('model:error', ({ error, modelUrl }) => { ... });
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
#### Emotions
|
|
66
|
+
|
|
67
|
+
`'neutral' | 'happy' | 'sad' | 'angry' | 'surprised' | 'thinking'`
|
|
68
|
+
|
|
69
|
+
### Custom TTS Engine
|
|
70
|
+
|
|
71
|
+
Implement `ITTSEngine` to use any TTS provider:
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
import type { ITTSEngine } from '@prometheusavatar/core';
|
|
75
|
+
|
|
76
|
+
class MyTTSEngine implements ITTSEngine {
|
|
77
|
+
async speak(text: string): Promise<void> { /* ... */ }
|
|
78
|
+
stop(): void { /* ... */ }
|
|
79
|
+
onAudioData?: (data: Float32Array) => void;
|
|
80
|
+
onEnd?: () => void;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const avatar = await createAvatar({
|
|
84
|
+
container: el,
|
|
85
|
+
modelUrl: url,
|
|
86
|
+
ttsEngine: new MyTTSEngine(),
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Architecture
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
PrometheusAvatar (orchestrator)
|
|
94
|
+
├── Live2DRenderer — PIXI.js + Live2D Cubism SDK
|
|
95
|
+
├── WebSpeechTTS — pluggable TTS (Web Speech API default)
|
|
96
|
+
├── LipSyncEngine — audio → mouth shape mapping
|
|
97
|
+
└── EmotionAnalyzer — text → emotion detection
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## License
|
|
101
|
+
|
|
102
|
+
MIT — [Myths Labs](https://github.com/myths-labs)
|
package/package.json
CHANGED