@charivo/tts 0.3.4 → 0.4.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 +0 -4
- package/dist/index.d.mts +3 -55
- package/dist/index.d.ts +3 -55
- package/dist/index.js +16 -24
- package/dist/index.mjs +15 -19
- package/dist/openai/index.d.mts +3 -28
- package/dist/openai/index.d.ts +3 -28
- package/dist/openai/index.js +2 -4
- package/dist/openai/index.mjs +2 -3
- package/dist/remote/index.d.mts +3 -27
- package/dist/remote/index.d.ts +3 -27
- package/dist/remote/index.js +2 -4
- package/dist/remote/index.mjs +2 -3
- package/dist/web/index.d.mts +3 -25
- package/dist/web/index.d.ts +3 -25
- package/dist/web/index.js +1 -3
- package/dist/web/index.mjs +1 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -32,10 +32,6 @@ await ttsManager.speak("Hello", { voice: "marin" });
|
|
|
32
32
|
## Exports
|
|
33
33
|
|
|
34
34
|
- `createTTSManager(player)`
|
|
35
|
-
- `WebSpeechLipSyncSimulator`
|
|
36
|
-
- `getTTSPlaybackMode(player)`
|
|
37
|
-
- `getTTSAudioMimeType(player)`
|
|
38
|
-
- `supportsGenerateAudio(player)`
|
|
39
35
|
|
|
40
36
|
## Event Bridge
|
|
41
37
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,60 +1,8 @@
|
|
|
1
|
-
import { TTSPlayer, TTSManager
|
|
1
|
+
import { TTSPlayer, TTSManager } from '@charivo/core';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Helper function to create a TTS Manager
|
|
5
5
|
*/
|
|
6
6
|
declare function createTTSManager(ttsPlayer: TTSPlayer): TTSManager;
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
* Web Speech Lip Sync Simulator
|
|
10
|
-
*
|
|
11
|
-
* Web Speech API용 텍스트 기반 립싱크 시뮬레이션
|
|
12
|
-
* 단어의 모음 개수와 길이를 기반으로 입 움직임을 시뮬레이션
|
|
13
|
-
*/
|
|
14
|
-
declare class WebSpeechLipSyncSimulator {
|
|
15
|
-
private intervals;
|
|
16
|
-
private eventEmitter?;
|
|
17
|
-
constructor(eventEmitter?: CharivoEventEmitter);
|
|
18
|
-
/**
|
|
19
|
-
* 텍스트 기반 립싱크 시뮬레이션 시작
|
|
20
|
-
*/
|
|
21
|
-
startSimulation(text: string, rate?: number): void;
|
|
22
|
-
/**
|
|
23
|
-
* 페이드 아웃 효과 생성
|
|
24
|
-
*/
|
|
25
|
-
private createFadeEffect;
|
|
26
|
-
/**
|
|
27
|
-
* 시뮬레이션 중지
|
|
28
|
-
*/
|
|
29
|
-
stopSimulation(): void;
|
|
30
|
-
/**
|
|
31
|
-
* 인터벌 정리
|
|
32
|
-
*/
|
|
33
|
-
private clearIntervals;
|
|
34
|
-
/**
|
|
35
|
-
* 리소스 정리
|
|
36
|
-
*/
|
|
37
|
-
dispose(): void;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* TTS Player Capability Utilities
|
|
42
|
-
*/
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Resolve the playback mode used by the manager. Concrete players should
|
|
46
|
-
* provide `playbackMode`. The default fallback is `"audio"`.
|
|
47
|
-
*/
|
|
48
|
-
declare function getTTSPlaybackMode(player: TTSPlayer): TTSPlaybackMode;
|
|
49
|
-
/**
|
|
50
|
-
* Resolve the MIME type used when generated audio is wrapped in a Blob.
|
|
51
|
-
*/
|
|
52
|
-
declare function getTTSAudioMimeType(player: TTSPlayer): string;
|
|
53
|
-
/**
|
|
54
|
-
* TTS Player가 generateAudio 메서드를 지원하는지 확인
|
|
55
|
-
*/
|
|
56
|
-
declare function supportsGenerateAudio(player: TTSPlayer): player is TTSPlayer & {
|
|
57
|
-
generateAudio(text: string, options?: TTSOptions): Promise<ArrayBuffer>;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export { WebSpeechLipSyncSimulator, createTTSManager, getTTSAudioMimeType, getTTSPlaybackMode, supportsGenerateAudio };
|
|
8
|
+
export { createTTSManager };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,60 +1,8 @@
|
|
|
1
|
-
import { TTSPlayer, TTSManager
|
|
1
|
+
import { TTSPlayer, TTSManager } from '@charivo/core';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Helper function to create a TTS Manager
|
|
5
5
|
*/
|
|
6
6
|
declare function createTTSManager(ttsPlayer: TTSPlayer): TTSManager;
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
* Web Speech Lip Sync Simulator
|
|
10
|
-
*
|
|
11
|
-
* Web Speech API용 텍스트 기반 립싱크 시뮬레이션
|
|
12
|
-
* 단어의 모음 개수와 길이를 기반으로 입 움직임을 시뮬레이션
|
|
13
|
-
*/
|
|
14
|
-
declare class WebSpeechLipSyncSimulator {
|
|
15
|
-
private intervals;
|
|
16
|
-
private eventEmitter?;
|
|
17
|
-
constructor(eventEmitter?: CharivoEventEmitter);
|
|
18
|
-
/**
|
|
19
|
-
* 텍스트 기반 립싱크 시뮬레이션 시작
|
|
20
|
-
*/
|
|
21
|
-
startSimulation(text: string, rate?: number): void;
|
|
22
|
-
/**
|
|
23
|
-
* 페이드 아웃 효과 생성
|
|
24
|
-
*/
|
|
25
|
-
private createFadeEffect;
|
|
26
|
-
/**
|
|
27
|
-
* 시뮬레이션 중지
|
|
28
|
-
*/
|
|
29
|
-
stopSimulation(): void;
|
|
30
|
-
/**
|
|
31
|
-
* 인터벌 정리
|
|
32
|
-
*/
|
|
33
|
-
private clearIntervals;
|
|
34
|
-
/**
|
|
35
|
-
* 리소스 정리
|
|
36
|
-
*/
|
|
37
|
-
dispose(): void;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* TTS Player Capability Utilities
|
|
42
|
-
*/
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Resolve the playback mode used by the manager. Concrete players should
|
|
46
|
-
* provide `playbackMode`. The default fallback is `"audio"`.
|
|
47
|
-
*/
|
|
48
|
-
declare function getTTSPlaybackMode(player: TTSPlayer): TTSPlaybackMode;
|
|
49
|
-
/**
|
|
50
|
-
* Resolve the MIME type used when generated audio is wrapped in a Blob.
|
|
51
|
-
*/
|
|
52
|
-
declare function getTTSAudioMimeType(player: TTSPlayer): string;
|
|
53
|
-
/**
|
|
54
|
-
* TTS Player가 generateAudio 메서드를 지원하는지 확인
|
|
55
|
-
*/
|
|
56
|
-
declare function supportsGenerateAudio(player: TTSPlayer): player is TTSPlayer & {
|
|
57
|
-
generateAudio(text: string, options?: TTSOptions): Promise<ArrayBuffer>;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export { WebSpeechLipSyncSimulator, createTTSManager, getTTSAudioMimeType, getTTSPlaybackMode, supportsGenerateAudio };
|
|
8
|
+
export { createTTSManager };
|
package/dist/index.js
CHANGED
|
@@ -20,11 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
-
|
|
24
|
-
createTTSManager: () => createTTSManager,
|
|
25
|
-
getTTSAudioMimeType: () => getTTSAudioMimeType,
|
|
26
|
-
getTTSPlaybackMode: () => getTTSPlaybackMode,
|
|
27
|
-
supportsGenerateAudio: () => supportsGenerateAudio
|
|
23
|
+
createTTSManager: () => createTTSManager
|
|
28
24
|
});
|
|
29
25
|
module.exports = __toCommonJS(index_exports);
|
|
30
26
|
|
|
@@ -39,7 +35,7 @@ var WebSpeechLipSyncSimulator = class {
|
|
|
39
35
|
this.eventEmitter = eventEmitter;
|
|
40
36
|
}
|
|
41
37
|
/**
|
|
42
|
-
*
|
|
38
|
+
* Start text-based lip-sync simulation
|
|
43
39
|
*/
|
|
44
40
|
startSimulation(text, rate = 1) {
|
|
45
41
|
this.clearIntervals();
|
|
@@ -59,7 +55,7 @@ var WebSpeechLipSyncSimulator = class {
|
|
|
59
55
|
});
|
|
60
56
|
}
|
|
61
57
|
/**
|
|
62
|
-
*
|
|
58
|
+
* Create fade-out effect
|
|
63
59
|
*/
|
|
64
60
|
createFadeEffect(intensity, duration) {
|
|
65
61
|
const fadeSteps = 3;
|
|
@@ -77,7 +73,7 @@ var WebSpeechLipSyncSimulator = class {
|
|
|
77
73
|
}
|
|
78
74
|
}
|
|
79
75
|
/**
|
|
80
|
-
*
|
|
76
|
+
* Stop simulation
|
|
81
77
|
*/
|
|
82
78
|
stopSimulation() {
|
|
83
79
|
this.clearIntervals();
|
|
@@ -86,14 +82,14 @@ var WebSpeechLipSyncSimulator = class {
|
|
|
86
82
|
}
|
|
87
83
|
}
|
|
88
84
|
/**
|
|
89
|
-
*
|
|
85
|
+
* Clear intervals
|
|
90
86
|
*/
|
|
91
87
|
clearIntervals() {
|
|
92
88
|
this.intervals.forEach((id) => clearTimeout(id));
|
|
93
89
|
this.intervals = [];
|
|
94
90
|
}
|
|
95
91
|
/**
|
|
96
|
-
*
|
|
92
|
+
* Dispose resources
|
|
97
93
|
*/
|
|
98
94
|
dispose() {
|
|
99
95
|
this.stopSimulation();
|
|
@@ -119,7 +115,7 @@ var TTSManagerImpl = class {
|
|
|
119
115
|
currentAudioUrl = null;
|
|
120
116
|
playbackMode;
|
|
121
117
|
isAudioSessionActive = false;
|
|
122
|
-
// Web Speech
|
|
118
|
+
// Only the Web Speech lip-sync simulation is needed
|
|
123
119
|
webSimulator;
|
|
124
120
|
constructor(ttsPlayer) {
|
|
125
121
|
this.ttsPlayer = ttsPlayer;
|
|
@@ -127,14 +123,14 @@ var TTSManagerImpl = class {
|
|
|
127
123
|
this.webSimulator = new WebSpeechLipSyncSimulator();
|
|
128
124
|
}
|
|
129
125
|
/**
|
|
130
|
-
*
|
|
126
|
+
* Set the event emitter
|
|
131
127
|
*/
|
|
132
128
|
setEventEmitter(eventEmitter) {
|
|
133
129
|
this.eventEmitter = eventEmitter;
|
|
134
130
|
this.webSimulator = new WebSpeechLipSyncSimulator(eventEmitter);
|
|
135
131
|
}
|
|
136
132
|
/**
|
|
137
|
-
*
|
|
133
|
+
* Convert text to speech and play it
|
|
138
134
|
*/
|
|
139
135
|
async speak(text, options) {
|
|
140
136
|
try {
|
|
@@ -151,7 +147,7 @@ var TTSManagerImpl = class {
|
|
|
151
147
|
}
|
|
152
148
|
}
|
|
153
149
|
/**
|
|
154
|
-
*
|
|
150
|
+
* Stop the currently playing speech
|
|
155
151
|
*/
|
|
156
152
|
async stop() {
|
|
157
153
|
this.webSimulator.stopSimulation();
|
|
@@ -175,19 +171,19 @@ var TTSManagerImpl = class {
|
|
|
175
171
|
}
|
|
176
172
|
}
|
|
177
173
|
/**
|
|
178
|
-
*
|
|
174
|
+
* Set the voice
|
|
179
175
|
*/
|
|
180
176
|
setVoice(voice) {
|
|
181
177
|
this.ttsPlayer.setVoice(voice);
|
|
182
178
|
}
|
|
183
179
|
/**
|
|
184
|
-
*
|
|
180
|
+
* Check support
|
|
185
181
|
*/
|
|
186
182
|
isSupported() {
|
|
187
183
|
return this.ttsPlayer.isSupported();
|
|
188
184
|
}
|
|
189
185
|
/**
|
|
190
|
-
* Web Speech API
|
|
186
|
+
* Handle the Web Speech API (simulated lip-sync)
|
|
191
187
|
*/
|
|
192
188
|
async handleWebSpeech(text, options) {
|
|
193
189
|
const dummyAudio = document.createElement("audio");
|
|
@@ -203,7 +199,7 @@ var TTSManagerImpl = class {
|
|
|
203
199
|
}
|
|
204
200
|
}
|
|
205
201
|
/**
|
|
206
|
-
*
|
|
202
|
+
* Handle audio-based TTS (real-time audio analysis)
|
|
207
203
|
*/
|
|
208
204
|
async handleAudioSpeech(text, options) {
|
|
209
205
|
if (supportsGenerateAudio(this.ttsPlayer)) {
|
|
@@ -217,7 +213,7 @@ var TTSManagerImpl = class {
|
|
|
217
213
|
}
|
|
218
214
|
}
|
|
219
215
|
/**
|
|
220
|
-
* Stateless
|
|
216
|
+
* Stateless audio handling
|
|
221
217
|
*/
|
|
222
218
|
async handleStatelessAudio(text, options) {
|
|
223
219
|
const audioData = await this.ttsPlayer.generateAudio(text, options).catch(
|
|
@@ -283,9 +279,5 @@ function createTTSManager(ttsPlayer) {
|
|
|
283
279
|
}
|
|
284
280
|
// Annotate the CommonJS export names for ESM import in node:
|
|
285
281
|
0 && (module.exports = {
|
|
286
|
-
|
|
287
|
-
createTTSManager,
|
|
288
|
-
getTTSAudioMimeType,
|
|
289
|
-
getTTSPlaybackMode,
|
|
290
|
-
supportsGenerateAudio
|
|
282
|
+
createTTSManager
|
|
291
283
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -11,7 +11,7 @@ var WebSpeechLipSyncSimulator = class {
|
|
|
11
11
|
this.eventEmitter = eventEmitter;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* Start text-based lip-sync simulation
|
|
15
15
|
*/
|
|
16
16
|
startSimulation(text, rate = 1) {
|
|
17
17
|
this.clearIntervals();
|
|
@@ -31,7 +31,7 @@ var WebSpeechLipSyncSimulator = class {
|
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
34
|
+
* Create fade-out effect
|
|
35
35
|
*/
|
|
36
36
|
createFadeEffect(intensity, duration) {
|
|
37
37
|
const fadeSteps = 3;
|
|
@@ -49,7 +49,7 @@ var WebSpeechLipSyncSimulator = class {
|
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
52
|
-
*
|
|
52
|
+
* Stop simulation
|
|
53
53
|
*/
|
|
54
54
|
stopSimulation() {
|
|
55
55
|
this.clearIntervals();
|
|
@@ -58,14 +58,14 @@ var WebSpeechLipSyncSimulator = class {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
/**
|
|
61
|
-
*
|
|
61
|
+
* Clear intervals
|
|
62
62
|
*/
|
|
63
63
|
clearIntervals() {
|
|
64
64
|
this.intervals.forEach((id) => clearTimeout(id));
|
|
65
65
|
this.intervals = [];
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
68
|
-
*
|
|
68
|
+
* Dispose resources
|
|
69
69
|
*/
|
|
70
70
|
dispose() {
|
|
71
71
|
this.stopSimulation();
|
|
@@ -91,7 +91,7 @@ var TTSManagerImpl = class {
|
|
|
91
91
|
currentAudioUrl = null;
|
|
92
92
|
playbackMode;
|
|
93
93
|
isAudioSessionActive = false;
|
|
94
|
-
// Web Speech
|
|
94
|
+
// Only the Web Speech lip-sync simulation is needed
|
|
95
95
|
webSimulator;
|
|
96
96
|
constructor(ttsPlayer) {
|
|
97
97
|
this.ttsPlayer = ttsPlayer;
|
|
@@ -99,14 +99,14 @@ var TTSManagerImpl = class {
|
|
|
99
99
|
this.webSimulator = new WebSpeechLipSyncSimulator();
|
|
100
100
|
}
|
|
101
101
|
/**
|
|
102
|
-
*
|
|
102
|
+
* Set the event emitter
|
|
103
103
|
*/
|
|
104
104
|
setEventEmitter(eventEmitter) {
|
|
105
105
|
this.eventEmitter = eventEmitter;
|
|
106
106
|
this.webSimulator = new WebSpeechLipSyncSimulator(eventEmitter);
|
|
107
107
|
}
|
|
108
108
|
/**
|
|
109
|
-
*
|
|
109
|
+
* Convert text to speech and play it
|
|
110
110
|
*/
|
|
111
111
|
async speak(text, options) {
|
|
112
112
|
try {
|
|
@@ -123,7 +123,7 @@ var TTSManagerImpl = class {
|
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
/**
|
|
126
|
-
*
|
|
126
|
+
* Stop the currently playing speech
|
|
127
127
|
*/
|
|
128
128
|
async stop() {
|
|
129
129
|
this.webSimulator.stopSimulation();
|
|
@@ -147,19 +147,19 @@ var TTSManagerImpl = class {
|
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
/**
|
|
150
|
-
*
|
|
150
|
+
* Set the voice
|
|
151
151
|
*/
|
|
152
152
|
setVoice(voice) {
|
|
153
153
|
this.ttsPlayer.setVoice(voice);
|
|
154
154
|
}
|
|
155
155
|
/**
|
|
156
|
-
*
|
|
156
|
+
* Check support
|
|
157
157
|
*/
|
|
158
158
|
isSupported() {
|
|
159
159
|
return this.ttsPlayer.isSupported();
|
|
160
160
|
}
|
|
161
161
|
/**
|
|
162
|
-
* Web Speech API
|
|
162
|
+
* Handle the Web Speech API (simulated lip-sync)
|
|
163
163
|
*/
|
|
164
164
|
async handleWebSpeech(text, options) {
|
|
165
165
|
const dummyAudio = document.createElement("audio");
|
|
@@ -175,7 +175,7 @@ var TTSManagerImpl = class {
|
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
177
|
/**
|
|
178
|
-
*
|
|
178
|
+
* Handle audio-based TTS (real-time audio analysis)
|
|
179
179
|
*/
|
|
180
180
|
async handleAudioSpeech(text, options) {
|
|
181
181
|
if (supportsGenerateAudio(this.ttsPlayer)) {
|
|
@@ -189,7 +189,7 @@ var TTSManagerImpl = class {
|
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
/**
|
|
192
|
-
* Stateless
|
|
192
|
+
* Stateless audio handling
|
|
193
193
|
*/
|
|
194
194
|
async handleStatelessAudio(text, options) {
|
|
195
195
|
const audioData = await this.ttsPlayer.generateAudio(text, options).catch(
|
|
@@ -254,9 +254,5 @@ function createTTSManager(ttsPlayer) {
|
|
|
254
254
|
return new TTSManagerImpl(ttsPlayer);
|
|
255
255
|
}
|
|
256
256
|
export {
|
|
257
|
-
|
|
258
|
-
createTTSManager,
|
|
259
|
-
getTTSAudioMimeType,
|
|
260
|
-
getTTSPlaybackMode,
|
|
261
|
-
supportsGenerateAudio
|
|
257
|
+
createTTSManager
|
|
262
258
|
};
|
package/dist/openai/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TTSPlayer
|
|
1
|
+
import { TTSPlayer } from '@charivo/core';
|
|
2
2
|
|
|
3
3
|
type OpenAITTSModel = "tts-1" | "tts-1-hd" | "gpt-4o-mini-tts";
|
|
4
4
|
interface OpenAITTSConfig {
|
|
@@ -9,31 +9,6 @@ interface OpenAITTSConfig {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
type OpenAITTSPlayerConfig = OpenAITTSConfig;
|
|
12
|
-
|
|
13
|
-
* OpenAI TTS Player - OpenAI provider를 래핑한 Stateless TTS Player
|
|
14
|
-
*
|
|
15
|
-
* 로컬 개발이나 테스트 환경에서 사용. 프로덕션에서는 보안상 권장하지 않음.
|
|
16
|
-
* API 키가 클라이언트에 노출되므로 서버 환경에서만 사용하거나 테스트용으로만 사용해야 함.
|
|
17
|
-
*
|
|
18
|
-
* Stateless 설계: 오디오 재생과 립싱크는 TTS Manager에서 담당
|
|
19
|
-
*/
|
|
20
|
-
declare class OpenAITTSPlayer implements TTSPlayer {
|
|
21
|
-
readonly playbackMode: "audio";
|
|
22
|
-
readonly audioMimeType = "audio/wav";
|
|
23
|
-
private provider;
|
|
24
|
-
constructor(config: OpenAITTSPlayerConfig);
|
|
25
|
-
/**
|
|
26
|
-
* Stateless 오디오 생성 (TTS Manager에서 사용)
|
|
27
|
-
*/
|
|
28
|
-
generateAudio(text: string, options?: TTSOptions): Promise<ArrayBuffer>;
|
|
29
|
-
/**
|
|
30
|
-
* Legacy speak 메서드 (호환성을 위해 유지)
|
|
31
|
-
*/
|
|
32
|
-
speak(text: string, options?: TTSOptions): Promise<void>;
|
|
33
|
-
stop(): Promise<void>;
|
|
34
|
-
setVoice(voice: string): void;
|
|
35
|
-
isSupported(): boolean;
|
|
36
|
-
}
|
|
37
|
-
declare function createOpenAITTSPlayer(config: OpenAITTSPlayerConfig): OpenAITTSPlayer;
|
|
12
|
+
declare function createOpenAITTSPlayer(config: OpenAITTSPlayerConfig): TTSPlayer;
|
|
38
13
|
|
|
39
|
-
export {
|
|
14
|
+
export { type OpenAITTSPlayerConfig, createOpenAITTSPlayer };
|
package/dist/openai/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TTSPlayer
|
|
1
|
+
import { TTSPlayer } from '@charivo/core';
|
|
2
2
|
|
|
3
3
|
type OpenAITTSModel = "tts-1" | "tts-1-hd" | "gpt-4o-mini-tts";
|
|
4
4
|
interface OpenAITTSConfig {
|
|
@@ -9,31 +9,6 @@ interface OpenAITTSConfig {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
type OpenAITTSPlayerConfig = OpenAITTSConfig;
|
|
12
|
-
|
|
13
|
-
* OpenAI TTS Player - OpenAI provider를 래핑한 Stateless TTS Player
|
|
14
|
-
*
|
|
15
|
-
* 로컬 개발이나 테스트 환경에서 사용. 프로덕션에서는 보안상 권장하지 않음.
|
|
16
|
-
* API 키가 클라이언트에 노출되므로 서버 환경에서만 사용하거나 테스트용으로만 사용해야 함.
|
|
17
|
-
*
|
|
18
|
-
* Stateless 설계: 오디오 재생과 립싱크는 TTS Manager에서 담당
|
|
19
|
-
*/
|
|
20
|
-
declare class OpenAITTSPlayer implements TTSPlayer {
|
|
21
|
-
readonly playbackMode: "audio";
|
|
22
|
-
readonly audioMimeType = "audio/wav";
|
|
23
|
-
private provider;
|
|
24
|
-
constructor(config: OpenAITTSPlayerConfig);
|
|
25
|
-
/**
|
|
26
|
-
* Stateless 오디오 생성 (TTS Manager에서 사용)
|
|
27
|
-
*/
|
|
28
|
-
generateAudio(text: string, options?: TTSOptions): Promise<ArrayBuffer>;
|
|
29
|
-
/**
|
|
30
|
-
* Legacy speak 메서드 (호환성을 위해 유지)
|
|
31
|
-
*/
|
|
32
|
-
speak(text: string, options?: TTSOptions): Promise<void>;
|
|
33
|
-
stop(): Promise<void>;
|
|
34
|
-
setVoice(voice: string): void;
|
|
35
|
-
isSupported(): boolean;
|
|
36
|
-
}
|
|
37
|
-
declare function createOpenAITTSPlayer(config: OpenAITTSPlayerConfig): OpenAITTSPlayer;
|
|
12
|
+
declare function createOpenAITTSPlayer(config: OpenAITTSPlayerConfig): TTSPlayer;
|
|
38
13
|
|
|
39
|
-
export {
|
|
14
|
+
export { type OpenAITTSPlayerConfig, createOpenAITTSPlayer };
|
package/dist/openai/index.js
CHANGED
|
@@ -30,7 +30,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/openai/index.ts
|
|
31
31
|
var openai_exports = {};
|
|
32
32
|
__export(openai_exports, {
|
|
33
|
-
OpenAITTSPlayer: () => OpenAITTSPlayer,
|
|
34
33
|
createOpenAITTSPlayer: () => createOpenAITTSPlayer
|
|
35
34
|
});
|
|
36
35
|
module.exports = __toCommonJS(openai_exports);
|
|
@@ -114,13 +113,13 @@ var OpenAITTSPlayer = class {
|
|
|
114
113
|
});
|
|
115
114
|
}
|
|
116
115
|
/**
|
|
117
|
-
* Stateless
|
|
116
|
+
* Stateless audio generation (used by the TTS Manager)
|
|
118
117
|
*/
|
|
119
118
|
async generateAudio(text, options) {
|
|
120
119
|
return this.provider.generateSpeech(text, options);
|
|
121
120
|
}
|
|
122
121
|
/**
|
|
123
|
-
* Legacy speak
|
|
122
|
+
* Legacy speak method (kept for compatibility)
|
|
124
123
|
*/
|
|
125
124
|
async speak(text, options) {
|
|
126
125
|
const audioBuffer = await this.generateAudio(text, options);
|
|
@@ -156,6 +155,5 @@ function createOpenAITTSPlayer(config) {
|
|
|
156
155
|
}
|
|
157
156
|
// Annotate the CommonJS export names for ESM import in node:
|
|
158
157
|
0 && (module.exports = {
|
|
159
|
-
OpenAITTSPlayer,
|
|
160
158
|
createOpenAITTSPlayer
|
|
161
159
|
});
|
package/dist/openai/index.mjs
CHANGED
|
@@ -81,13 +81,13 @@ var OpenAITTSPlayer = class {
|
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
83
|
/**
|
|
84
|
-
* Stateless
|
|
84
|
+
* Stateless audio generation (used by the TTS Manager)
|
|
85
85
|
*/
|
|
86
86
|
async generateAudio(text, options) {
|
|
87
87
|
return this.provider.generateSpeech(text, options);
|
|
88
88
|
}
|
|
89
89
|
/**
|
|
90
|
-
* Legacy speak
|
|
90
|
+
* Legacy speak method (kept for compatibility)
|
|
91
91
|
*/
|
|
92
92
|
async speak(text, options) {
|
|
93
93
|
const audioBuffer = await this.generateAudio(text, options);
|
|
@@ -122,6 +122,5 @@ function createOpenAITTSPlayer(config) {
|
|
|
122
122
|
return new OpenAITTSPlayer(config);
|
|
123
123
|
}
|
|
124
124
|
export {
|
|
125
|
-
OpenAITTSPlayer,
|
|
126
125
|
createOpenAITTSPlayer
|
|
127
126
|
};
|
package/dist/remote/index.d.mts
CHANGED
|
@@ -1,33 +1,9 @@
|
|
|
1
|
-
import { TTSPlayer
|
|
1
|
+
import { TTSPlayer } from '@charivo/core';
|
|
2
2
|
|
|
3
3
|
interface RemoteTTSConfig {
|
|
4
4
|
apiEndpoint?: string;
|
|
5
5
|
defaultVoice?: string;
|
|
6
6
|
}
|
|
7
|
-
|
|
8
|
-
* Remote TTS Player - 원격 서버의 TTS API를 사용하는 Stateless TTS Player
|
|
9
|
-
*
|
|
10
|
-
* 서버에서 TTS를 처리하고 오디오 데이터를 받아옴
|
|
11
|
-
* Stateless 설계: 오디오 재생과 립싱크는 TTS Manager에서 담당
|
|
12
|
-
*/
|
|
13
|
-
declare class RemoteTTSPlayer implements TTSPlayer {
|
|
14
|
-
readonly playbackMode: "audio";
|
|
15
|
-
readonly audioMimeType = "audio/wav";
|
|
16
|
-
private apiEndpoint;
|
|
17
|
-
private defaultVoice;
|
|
18
|
-
constructor(config?: RemoteTTSConfig);
|
|
19
|
-
/**
|
|
20
|
-
* Stateless 오디오 생성 (TTS Manager에서 사용)
|
|
21
|
-
*/
|
|
22
|
-
generateAudio(text: string, options?: TTSOptions): Promise<ArrayBuffer>;
|
|
23
|
-
/**
|
|
24
|
-
* Legacy speak 메서드 (호환성을 위해 유지)
|
|
25
|
-
*/
|
|
26
|
-
speak(text: string, options?: TTSOptions): Promise<void>;
|
|
27
|
-
stop(): Promise<void>;
|
|
28
|
-
setVoice(voice: string): void;
|
|
29
|
-
isSupported(): boolean;
|
|
30
|
-
}
|
|
31
|
-
declare function createRemoteTTSPlayer(config?: RemoteTTSConfig): RemoteTTSPlayer;
|
|
7
|
+
declare function createRemoteTTSPlayer(config?: RemoteTTSConfig): TTSPlayer;
|
|
32
8
|
|
|
33
|
-
export { type RemoteTTSConfig,
|
|
9
|
+
export { type RemoteTTSConfig, createRemoteTTSPlayer };
|
package/dist/remote/index.d.ts
CHANGED
|
@@ -1,33 +1,9 @@
|
|
|
1
|
-
import { TTSPlayer
|
|
1
|
+
import { TTSPlayer } from '@charivo/core';
|
|
2
2
|
|
|
3
3
|
interface RemoteTTSConfig {
|
|
4
4
|
apiEndpoint?: string;
|
|
5
5
|
defaultVoice?: string;
|
|
6
6
|
}
|
|
7
|
-
|
|
8
|
-
* Remote TTS Player - 원격 서버의 TTS API를 사용하는 Stateless TTS Player
|
|
9
|
-
*
|
|
10
|
-
* 서버에서 TTS를 처리하고 오디오 데이터를 받아옴
|
|
11
|
-
* Stateless 설계: 오디오 재생과 립싱크는 TTS Manager에서 담당
|
|
12
|
-
*/
|
|
13
|
-
declare class RemoteTTSPlayer implements TTSPlayer {
|
|
14
|
-
readonly playbackMode: "audio";
|
|
15
|
-
readonly audioMimeType = "audio/wav";
|
|
16
|
-
private apiEndpoint;
|
|
17
|
-
private defaultVoice;
|
|
18
|
-
constructor(config?: RemoteTTSConfig);
|
|
19
|
-
/**
|
|
20
|
-
* Stateless 오디오 생성 (TTS Manager에서 사용)
|
|
21
|
-
*/
|
|
22
|
-
generateAudio(text: string, options?: TTSOptions): Promise<ArrayBuffer>;
|
|
23
|
-
/**
|
|
24
|
-
* Legacy speak 메서드 (호환성을 위해 유지)
|
|
25
|
-
*/
|
|
26
|
-
speak(text: string, options?: TTSOptions): Promise<void>;
|
|
27
|
-
stop(): Promise<void>;
|
|
28
|
-
setVoice(voice: string): void;
|
|
29
|
-
isSupported(): boolean;
|
|
30
|
-
}
|
|
31
|
-
declare function createRemoteTTSPlayer(config?: RemoteTTSConfig): RemoteTTSPlayer;
|
|
7
|
+
declare function createRemoteTTSPlayer(config?: RemoteTTSConfig): TTSPlayer;
|
|
32
8
|
|
|
33
|
-
export { type RemoteTTSConfig,
|
|
9
|
+
export { type RemoteTTSConfig, createRemoteTTSPlayer };
|
package/dist/remote/index.js
CHANGED
|
@@ -20,7 +20,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/remote/index.ts
|
|
21
21
|
var remote_exports = {};
|
|
22
22
|
__export(remote_exports, {
|
|
23
|
-
RemoteTTSPlayer: () => RemoteTTSPlayer,
|
|
24
23
|
createRemoteTTSPlayer: () => createRemoteTTSPlayer
|
|
25
24
|
});
|
|
26
25
|
module.exports = __toCommonJS(remote_exports);
|
|
@@ -36,7 +35,7 @@ var RemoteTTSPlayer = class {
|
|
|
36
35
|
this.defaultVoice = config.defaultVoice || "marin";
|
|
37
36
|
}
|
|
38
37
|
/**
|
|
39
|
-
* Stateless
|
|
38
|
+
* Stateless audio generation (used by the TTS Manager)
|
|
40
39
|
*/
|
|
41
40
|
async generateAudio(text, options) {
|
|
42
41
|
const response = await fetchWithTimeout(
|
|
@@ -59,7 +58,7 @@ var RemoteTTSPlayer = class {
|
|
|
59
58
|
return response.arrayBuffer();
|
|
60
59
|
}
|
|
61
60
|
/**
|
|
62
|
-
* Legacy speak
|
|
61
|
+
* Legacy speak method (kept for compatibility)
|
|
63
62
|
*/
|
|
64
63
|
async speak(text, options) {
|
|
65
64
|
const audioBuffer = await this.generateAudio(text, options);
|
|
@@ -117,6 +116,5 @@ function isAbortError(error) {
|
|
|
117
116
|
}
|
|
118
117
|
// Annotate the CommonJS export names for ESM import in node:
|
|
119
118
|
0 && (module.exports = {
|
|
120
|
-
RemoteTTSPlayer,
|
|
121
119
|
createRemoteTTSPlayer
|
|
122
120
|
});
|
package/dist/remote/index.mjs
CHANGED
|
@@ -15,7 +15,7 @@ var RemoteTTSPlayer = class {
|
|
|
15
15
|
this.defaultVoice = config.defaultVoice || "marin";
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
-
* Stateless
|
|
18
|
+
* Stateless audio generation (used by the TTS Manager)
|
|
19
19
|
*/
|
|
20
20
|
async generateAudio(text, options) {
|
|
21
21
|
const response = await fetchWithTimeout(
|
|
@@ -38,7 +38,7 @@ var RemoteTTSPlayer = class {
|
|
|
38
38
|
return response.arrayBuffer();
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
|
-
* Legacy speak
|
|
41
|
+
* Legacy speak method (kept for compatibility)
|
|
42
42
|
*/
|
|
43
43
|
async speak(text, options) {
|
|
44
44
|
const audioBuffer = await this.generateAudio(text, options);
|
|
@@ -95,6 +95,5 @@ function isAbortError(error) {
|
|
|
95
95
|
return error instanceof DOMException && error.name === "AbortError" || error instanceof Error && error.name === "AbortError";
|
|
96
96
|
}
|
|
97
97
|
export {
|
|
98
|
-
RemoteTTSPlayer,
|
|
99
98
|
createRemoteTTSPlayer
|
|
100
99
|
};
|
package/dist/web/index.d.mts
CHANGED
|
@@ -1,27 +1,5 @@
|
|
|
1
|
-
import { TTSPlayer
|
|
1
|
+
import { TTSPlayer } from '@charivo/core';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
* Web TTS Player - Web Speech API를 사용하는 Stateless TTS Player
|
|
5
|
-
*
|
|
6
|
-
* 브라우저 내장 TTS 기능을 사용
|
|
7
|
-
* Stateless 설계: 립싱크 시뮬레이션은 TTS Manager에서 담당
|
|
8
|
-
*/
|
|
9
|
-
declare class WebTTSPlayer implements TTSPlayer {
|
|
10
|
-
readonly playbackMode: "web-speech";
|
|
11
|
-
private synthesis;
|
|
12
|
-
private voices;
|
|
13
|
-
private defaultVoice?;
|
|
14
|
-
constructor();
|
|
15
|
-
private loadVoices;
|
|
16
|
-
private findVoice;
|
|
17
|
-
/**
|
|
18
|
-
* Simple speak 메서드 (TTS Manager에서 립싱크 처리)
|
|
19
|
-
*/
|
|
20
|
-
speak(text: string, options?: TTSOptions): Promise<void>;
|
|
21
|
-
stop(): Promise<void>;
|
|
22
|
-
setVoice(voiceId: string): void;
|
|
23
|
-
isSupported(): boolean;
|
|
24
|
-
}
|
|
25
|
-
declare function createWebTTSPlayer(): WebTTSPlayer;
|
|
3
|
+
declare function createWebTTSPlayer(): TTSPlayer;
|
|
26
4
|
|
|
27
|
-
export {
|
|
5
|
+
export { createWebTTSPlayer };
|
package/dist/web/index.d.ts
CHANGED
|
@@ -1,27 +1,5 @@
|
|
|
1
|
-
import { TTSPlayer
|
|
1
|
+
import { TTSPlayer } from '@charivo/core';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
* Web TTS Player - Web Speech API를 사용하는 Stateless TTS Player
|
|
5
|
-
*
|
|
6
|
-
* 브라우저 내장 TTS 기능을 사용
|
|
7
|
-
* Stateless 설계: 립싱크 시뮬레이션은 TTS Manager에서 담당
|
|
8
|
-
*/
|
|
9
|
-
declare class WebTTSPlayer implements TTSPlayer {
|
|
10
|
-
readonly playbackMode: "web-speech";
|
|
11
|
-
private synthesis;
|
|
12
|
-
private voices;
|
|
13
|
-
private defaultVoice?;
|
|
14
|
-
constructor();
|
|
15
|
-
private loadVoices;
|
|
16
|
-
private findVoice;
|
|
17
|
-
/**
|
|
18
|
-
* Simple speak 메서드 (TTS Manager에서 립싱크 처리)
|
|
19
|
-
*/
|
|
20
|
-
speak(text: string, options?: TTSOptions): Promise<void>;
|
|
21
|
-
stop(): Promise<void>;
|
|
22
|
-
setVoice(voiceId: string): void;
|
|
23
|
-
isSupported(): boolean;
|
|
24
|
-
}
|
|
25
|
-
declare function createWebTTSPlayer(): WebTTSPlayer;
|
|
3
|
+
declare function createWebTTSPlayer(): TTSPlayer;
|
|
26
4
|
|
|
27
|
-
export {
|
|
5
|
+
export { createWebTTSPlayer };
|
package/dist/web/index.js
CHANGED
|
@@ -20,7 +20,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/web/index.ts
|
|
21
21
|
var web_exports = {};
|
|
22
22
|
__export(web_exports, {
|
|
23
|
-
WebTTSPlayer: () => WebTTSPlayer,
|
|
24
23
|
createWebTTSPlayer: () => createWebTTSPlayer
|
|
25
24
|
});
|
|
26
25
|
module.exports = __toCommonJS(web_exports);
|
|
@@ -52,7 +51,7 @@ var WebTTSPlayer = class {
|
|
|
52
51
|
);
|
|
53
52
|
}
|
|
54
53
|
/**
|
|
55
|
-
* Simple speak
|
|
54
|
+
* Simple speak method (lip-sync is handled by the TTS Manager)
|
|
56
55
|
*/
|
|
57
56
|
async speak(text, options) {
|
|
58
57
|
return new Promise((resolve, reject) => {
|
|
@@ -108,6 +107,5 @@ function createWebTTSPlayer() {
|
|
|
108
107
|
}
|
|
109
108
|
// Annotate the CommonJS export names for ESM import in node:
|
|
110
109
|
0 && (module.exports = {
|
|
111
|
-
WebTTSPlayer,
|
|
112
110
|
createWebTTSPlayer
|
|
113
111
|
});
|
package/dist/web/index.mjs
CHANGED
|
@@ -27,7 +27,7 @@ var WebTTSPlayer = class {
|
|
|
27
27
|
);
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
|
-
* Simple speak
|
|
30
|
+
* Simple speak method (lip-sync is handled by the TTS Manager)
|
|
31
31
|
*/
|
|
32
32
|
async speak(text, options) {
|
|
33
33
|
return new Promise((resolve, reject) => {
|
|
@@ -82,6 +82,5 @@ function createWebTTSPlayer() {
|
|
|
82
82
|
return new WebTTSPlayer();
|
|
83
83
|
}
|
|
84
84
|
export {
|
|
85
|
-
WebTTSPlayer,
|
|
86
85
|
createWebTTSPlayer
|
|
87
86
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@charivo/tts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "TTS manager and browser adapters for Charivo",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"openai": "^4.47.1",
|
|
39
|
-
"@charivo/core": "0.
|
|
39
|
+
"@charivo/core": "0.14.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"tsup": "^8.5.0",
|