@charivo/stt-core 0.0.1 → 0.0.2
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 +17 -443
- package/dist/index.d.mts +2 -4
- package/dist/index.d.ts +2 -4
- package/dist/index.js +0 -7
- package/dist/index.mjs +0 -7
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -1,463 +1,37 @@
|
|
|
1
1
|
# @charivo/stt-core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Stateful STT manager and recording helper for Charivo.
|
|
4
4
|
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
- 🎤 **Transcription Coordination** - Manages STT transcribers with unified API
|
|
8
|
-
- 📡 **Event Bus Integration** - Emit audio events for recording lifecycle
|
|
9
|
-
- 🛠️ **MediaRecorder Helper** - Shared audio recording utility for transcribers
|
|
10
|
-
- 🔌 **Transcriber Agnostic** - Works with any STT transcriber (Web, OpenAI, Remote, etc.)
|
|
11
|
-
|
|
12
|
-
## Installation
|
|
5
|
+
## Install
|
|
13
6
|
|
|
14
7
|
```bash
|
|
15
|
-
pnpm add @charivo/stt-core
|
|
8
|
+
pnpm add @charivo/stt-core
|
|
16
9
|
```
|
|
17
10
|
|
|
18
11
|
## Usage
|
|
19
12
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
```typescript
|
|
13
|
+
```ts
|
|
23
14
|
import { createSTTManager } from "@charivo/stt-core";
|
|
24
15
|
import { createRemoteSTTTranscriber } from "@charivo/stt-transcriber-remote";
|
|
25
16
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
// Wrap with STTManager for event emission and coordination
|
|
32
|
-
const sttManager = createSTTManager(transcriber);
|
|
33
|
-
|
|
34
|
-
// Start recording (handled internally by transcriber)
|
|
35
|
-
await sttManager.start();
|
|
36
|
-
|
|
37
|
-
// Stop recording and get transcription
|
|
38
|
-
const transcription = await sttManager.stop();
|
|
39
|
-
console.log("User said:", transcription);
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
### With Event Bus
|
|
43
|
-
|
|
44
|
-
```typescript
|
|
45
|
-
import { EventBus } from "@charivo/core";
|
|
46
|
-
|
|
47
|
-
const eventBus = new EventBus();
|
|
48
|
-
const sttManager = createSTTManager(transcriber);
|
|
49
|
-
|
|
50
|
-
// Connect event bus
|
|
51
|
-
sttManager.setEventEmitter({
|
|
52
|
-
emit: (event, data) => eventBus.emit(event, data)
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
// Listen to events
|
|
56
|
-
eventBus.on("stt:start", (data) => {
|
|
57
|
-
console.log("Recording started", data);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
eventBus.on("stt:stop", (data) => {
|
|
61
|
-
console.log("Transcription:", data.transcription);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
eventBus.on("stt:error", (data) => {
|
|
65
|
-
console.error("STT error:", data.error);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
// Start recording
|
|
69
|
-
await sttManager.start();
|
|
70
|
-
// → "stt:start" emitted
|
|
71
|
-
|
|
72
|
-
// Stop and transcribe
|
|
73
|
-
const text = await sttManager.stop();
|
|
74
|
-
// → Recording stops (handled by transcriber)
|
|
75
|
-
// → Audio is transcribed
|
|
76
|
-
// → "stt:stop" emitted with transcription
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
### Custom STT Transcriber
|
|
80
|
-
|
|
81
|
-
Each transcriber handles recording internally:
|
|
82
|
-
|
|
83
|
-
```typescript
|
|
84
|
-
import { STTTranscriber, STTOptions } from "@charivo/core";
|
|
85
|
-
import { MediaRecorderHelper, createSTTManager } from "@charivo/stt-core";
|
|
86
|
-
|
|
87
|
-
class MyCustomSTTTranscriber implements STTTranscriber {
|
|
88
|
-
private recorder = new MediaRecorderHelper();
|
|
89
|
-
private recordingOptions?: STTOptions;
|
|
90
|
-
|
|
91
|
-
async startRecording(options?: STTOptions): Promise<void> {
|
|
92
|
-
this.recordingOptions = options;
|
|
93
|
-
await this.recorder.start();
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
async stopRecording(): Promise<string> {
|
|
97
|
-
const audioBlob = await this.recorder.stop();
|
|
98
|
-
|
|
99
|
-
// Call your STT API
|
|
100
|
-
const formData = new FormData();
|
|
101
|
-
formData.append("audio", audioBlob);
|
|
102
|
-
if (this.recordingOptions?.language) {
|
|
103
|
-
formData.append("language", this.recordingOptions.language);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const response = await fetch("https://my-stt-api.com/transcribe", {
|
|
107
|
-
method: "POST",
|
|
108
|
-
body: formData
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
const data = await response.json();
|
|
112
|
-
this.recordingOptions = undefined;
|
|
113
|
-
return data.transcription;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
isRecording(): boolean {
|
|
117
|
-
return this.recorder.isRecording();
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
const sttManager = createSTTManager(new MyCustomSTTTranscriber());
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
### Check Recording State
|
|
125
|
-
|
|
126
|
-
```typescript
|
|
127
|
-
// Check if currently recording
|
|
128
|
-
if (sttManager.isRecording()) {
|
|
129
|
-
console.log("Recording in progress...");
|
|
130
|
-
} else {
|
|
131
|
-
console.log("Not recording");
|
|
132
|
-
}
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
## API Reference
|
|
136
|
-
|
|
137
|
-
### `STTManager`
|
|
138
|
-
|
|
139
|
-
Main class for coordinating STT transcription and emitting events.
|
|
140
|
-
|
|
141
|
-
#### Constructor
|
|
142
|
-
|
|
143
|
-
```typescript
|
|
144
|
-
new STTManager(transcriber: STTTranscriber)
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
#### Methods
|
|
148
|
-
|
|
149
|
-
##### `setEventEmitter(eventEmitter)`
|
|
150
|
-
Connect event emitter for STT event emission.
|
|
151
|
-
|
|
152
|
-
```typescript
|
|
153
|
-
sttManager.setEventEmitter({
|
|
154
|
-
emit: (event, data) => { /* ... */ }
|
|
155
|
-
});
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
When set, the manager emits:
|
|
159
|
-
- `stt:start` with `{ options?: STTOptions }` when recording starts
|
|
160
|
-
- `stt:stop` with `{ transcription: string }` when transcription completes
|
|
161
|
-
- `stt:error` with `{ error: Error }` when an error occurs
|
|
162
|
-
|
|
163
|
-
##### `start(options?)`
|
|
164
|
-
Start audio recording (delegates to transcriber).
|
|
165
|
-
|
|
166
|
-
```typescript
|
|
167
|
-
await sttManager.start();
|
|
168
|
-
|
|
169
|
-
// With language option
|
|
170
|
-
await sttManager.start({ language: "en-US" });
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
The transcriber handles microphone access and recording internally.
|
|
174
|
-
|
|
175
|
-
##### `stop()`
|
|
176
|
-
Stop recording and get transcribed text (delegates to transcriber).
|
|
177
|
-
|
|
178
|
-
```typescript
|
|
179
|
-
const transcription = await sttManager.stop();
|
|
180
|
-
console.log("User said:", transcription);
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
Returns the transcribed text as a string.
|
|
184
|
-
|
|
185
|
-
##### `isRecording()`
|
|
186
|
-
Check if currently recording (delegates to transcriber).
|
|
187
|
-
|
|
188
|
-
```typescript
|
|
189
|
-
if (sttManager.isRecording()) {
|
|
190
|
-
console.log("Recording...");
|
|
191
|
-
}
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
### `MediaRecorderHelper`
|
|
195
|
-
|
|
196
|
-
Shared utility for audio recording (used by blob-based transcribers).
|
|
197
|
-
|
|
198
|
-
#### Methods
|
|
199
|
-
|
|
200
|
-
##### `start()`
|
|
201
|
-
Start audio recording from microphone.
|
|
202
|
-
|
|
203
|
-
```typescript
|
|
204
|
-
const recorder = new MediaRecorderHelper();
|
|
205
|
-
await recorder.start();
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
##### `stop()`
|
|
209
|
-
Stop recording and return audio blob.
|
|
210
|
-
|
|
211
|
-
```typescript
|
|
212
|
-
const audioBlob = await recorder.stop();
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
##### `isRecording()`
|
|
216
|
-
Check if currently recording.
|
|
217
|
-
|
|
218
|
-
```typescript
|
|
219
|
-
if (recorder.isRecording()) {
|
|
220
|
-
console.log("Recording...");
|
|
221
|
-
}
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
##### `abort()`
|
|
225
|
-
Abort recording immediately without returning data.
|
|
17
|
+
const sttManager = createSTTManager(
|
|
18
|
+
createRemoteSTTTranscriber({ apiEndpoint: "/api/stt" }),
|
|
19
|
+
);
|
|
226
20
|
|
|
227
|
-
|
|
228
|
-
recorder.abort();
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
## Events
|
|
232
|
-
|
|
233
|
-
### `stt:start`
|
|
234
|
-
|
|
235
|
-
Emitted when audio recording starts.
|
|
236
|
-
|
|
237
|
-
```typescript
|
|
238
|
-
{
|
|
239
|
-
options?: STTOptions
|
|
240
|
-
}
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
Use this to:
|
|
244
|
-
- Show "recording" indicator
|
|
245
|
-
- Disable other audio inputs
|
|
246
|
-
- Update UI state
|
|
247
|
-
|
|
248
|
-
### `stt:stop`
|
|
249
|
-
|
|
250
|
-
Emitted when audio recording stops and transcription completes.
|
|
251
|
-
|
|
252
|
-
```typescript
|
|
253
|
-
{
|
|
254
|
-
transcription: string
|
|
255
|
-
}
|
|
256
|
-
```
|
|
257
|
-
|
|
258
|
-
Use this to:
|
|
259
|
-
- Display transcribed text
|
|
260
|
-
- Hide "recording" indicator
|
|
261
|
-
- Process user input
|
|
262
|
-
|
|
263
|
-
### `stt:error`
|
|
264
|
-
|
|
265
|
-
Emitted when an error occurs during recording or transcription.
|
|
266
|
-
|
|
267
|
-
```typescript
|
|
268
|
-
{
|
|
269
|
-
error: Error
|
|
270
|
-
}
|
|
271
|
-
```
|
|
272
|
-
|
|
273
|
-
Use this to:
|
|
274
|
-
- Show error message to user
|
|
275
|
-
- Clean up UI state
|
|
276
|
-
- Retry logic
|
|
277
|
-
|
|
278
|
-
## Integration with Charivo
|
|
279
|
-
|
|
280
|
-
The STT system integrates seamlessly with the Charivo framework:
|
|
281
|
-
|
|
282
|
-
```typescript
|
|
283
|
-
import { Charivo } from "@charivo/core";
|
|
284
|
-
import { createSTTManager } from "@charivo/stt-core";
|
|
285
|
-
import { createWebSTTTranscriber } from "@charivo/stt-transcriber-web";
|
|
286
|
-
|
|
287
|
-
const charivo = new Charivo();
|
|
288
|
-
|
|
289
|
-
// Setup STT
|
|
290
|
-
const transcriber = createWebSTTTranscriber();
|
|
291
|
-
const sttManager = createSTTManager(transcriber);
|
|
292
|
-
charivo.attachSTT(sttManager);
|
|
293
|
-
|
|
294
|
-
// Start voice input
|
|
295
|
-
await sttManager.start();
|
|
296
|
-
|
|
297
|
-
// Stop and automatically send to character
|
|
298
|
-
const transcription = await sttManager.stop();
|
|
299
|
-
await charivo.userSay(transcription);
|
|
300
|
-
// → Character responds with voice and animation
|
|
301
|
-
```
|
|
302
|
-
|
|
303
|
-
## Architecture
|
|
304
|
-
|
|
305
|
-
```
|
|
306
|
-
STTManager (coordination layer)
|
|
307
|
-
├─ Event Emission
|
|
308
|
-
└─ STTTranscriber (handles recording internally)
|
|
309
|
-
├─ WebSTTTranscriber
|
|
310
|
-
│ └─ Web Speech API (real-time)
|
|
311
|
-
├─ OpenAISTTTranscriber
|
|
312
|
-
│ ├─ MediaRecorderHelper
|
|
313
|
-
│ └─ OpenAI Whisper API
|
|
314
|
-
└─ RemoteSTTTranscriber
|
|
315
|
-
├─ MediaRecorderHelper
|
|
316
|
-
└─ Your Server API
|
|
317
|
-
```
|
|
318
|
-
|
|
319
|
-
## Available Transcribers
|
|
320
|
-
|
|
321
|
-
### Web STT Transcriber (Free, Browser-native) ⭐ Recommended
|
|
322
|
-
|
|
323
|
-
```bash
|
|
324
|
-
pnpm add @charivo/stt-transcriber-web
|
|
325
|
-
```
|
|
326
|
-
|
|
327
|
-
```typescript
|
|
328
|
-
import { createWebSTTTranscriber } from "@charivo/stt-transcriber-web";
|
|
329
|
-
|
|
330
|
-
const transcriber = createWebSTTTranscriber();
|
|
331
|
-
const sttManager = createSTTManager(transcriber);
|
|
332
|
-
|
|
333
|
-
// Works with STTManager!
|
|
334
|
-
await sttManager.start({ language: "en-US" });
|
|
21
|
+
await sttManager.start({ language: "ko" });
|
|
335
22
|
const text = await sttManager.stop();
|
|
336
23
|
```
|
|
337
24
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
**Advantages:**
|
|
341
|
-
- 🆓 Completely free
|
|
342
|
-
- ⚡ Real-time recognition
|
|
343
|
-
- 🔒 No server required
|
|
344
|
-
- 🎯 Perfect for development and production
|
|
345
|
-
|
|
346
|
-
### Remote STT Transcriber (Production-ready)
|
|
347
|
-
|
|
348
|
-
```bash
|
|
349
|
-
pnpm add @charivo/stt-transcriber-remote
|
|
350
|
-
```
|
|
351
|
-
|
|
352
|
-
```typescript
|
|
353
|
-
import { createRemoteSTTTranscriber } from "@charivo/stt-transcriber-remote";
|
|
354
|
-
|
|
355
|
-
const transcriber = createRemoteSTTTranscriber({
|
|
356
|
-
apiEndpoint: "/api/stt" // Your server endpoint
|
|
357
|
-
});
|
|
358
|
-
```
|
|
359
|
-
|
|
360
|
-
Calls your server API to keep credentials secure.
|
|
361
|
-
|
|
362
|
-
### OpenAI STT Transcriber (Development/Testing Only)
|
|
363
|
-
|
|
364
|
-
```bash
|
|
365
|
-
pnpm add @charivo/stt-transcriber-openai
|
|
366
|
-
```
|
|
367
|
-
|
|
368
|
-
```typescript
|
|
369
|
-
import { createOpenAISTTTranscriber } from "@charivo/stt-transcriber-openai";
|
|
370
|
-
|
|
371
|
-
const transcriber = createOpenAISTTTranscriber({
|
|
372
|
-
apiKey: "your-api-key", // ⚠️ Exposed on client
|
|
373
|
-
defaultLanguage: "en"
|
|
374
|
-
});
|
|
375
|
-
```
|
|
376
|
-
|
|
377
|
-
⚠️ **Warning**: API key is exposed on the client. Only use for development/testing.
|
|
378
|
-
|
|
379
|
-
## Browser Compatibility
|
|
25
|
+
## Exports
|
|
380
26
|
|
|
381
|
-
|
|
27
|
+
- `STTManagerImpl`
|
|
28
|
+
- `createSTTManager(transcriber)`
|
|
29
|
+
- `MediaRecorderHelper`
|
|
382
30
|
|
|
383
|
-
|
|
384
|
-
- Chrome/Edge 49+
|
|
385
|
-
- Firefox 29+
|
|
386
|
-
- Safari 14.1+
|
|
387
|
-
|
|
388
|
-
**Web Speech API** (Web):
|
|
389
|
-
- Chrome/Edge (fully supported)
|
|
390
|
-
- Safari (limited support)
|
|
391
|
-
- Firefox (not supported)
|
|
392
|
-
|
|
393
|
-
## Error Handling
|
|
394
|
-
|
|
395
|
-
```typescript
|
|
396
|
-
try {
|
|
397
|
-
await sttManager.start();
|
|
398
|
-
const transcription = await sttManager.stop();
|
|
399
|
-
} catch (error) {
|
|
400
|
-
if (error.name === "NotAllowedError") {
|
|
401
|
-
console.error("Microphone permission denied");
|
|
402
|
-
} else if (error.name === "NotFoundError") {
|
|
403
|
-
console.error("No microphone found");
|
|
404
|
-
} else {
|
|
405
|
-
console.error("STT error:", error);
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
```
|
|
409
|
-
|
|
410
|
-
Common errors:
|
|
411
|
-
- `NotAllowedError` - User denied microphone permission
|
|
412
|
-
- `NotFoundError` - No microphone device available
|
|
413
|
-
- `NotReadableError` - Microphone is already in use
|
|
414
|
-
- Network errors - Transcription API failed
|
|
415
|
-
|
|
416
|
-
## Best Practices
|
|
417
|
-
|
|
418
|
-
1. **Use Web STT for most cases**: Free, fast, and browser-native
|
|
419
|
-
2. **Request permission early**: Test microphone access before starting recording
|
|
420
|
-
3. **Show recording indicator**: Always show visual feedback when recording
|
|
421
|
-
4. **Handle errors gracefully**: Provide clear error messages to users
|
|
422
|
-
|
|
423
|
-
```typescript
|
|
424
|
-
// React example
|
|
425
|
-
function VoiceInput() {
|
|
426
|
-
const [recording, setRecording] = useState(false);
|
|
427
|
-
const [error, setError] = useState<string | null>(null);
|
|
428
|
-
|
|
429
|
-
const handleStart = async () => {
|
|
430
|
-
try {
|
|
431
|
-
setError(null);
|
|
432
|
-
await sttManager.start();
|
|
433
|
-
setRecording(true);
|
|
434
|
-
} catch (err) {
|
|
435
|
-
setError("Failed to start recording");
|
|
436
|
-
}
|
|
437
|
-
};
|
|
438
|
-
|
|
439
|
-
const handleStop = async () => {
|
|
440
|
-
try {
|
|
441
|
-
const text = await sttManager.stop();
|
|
442
|
-
setRecording(false);
|
|
443
|
-
onTranscription(text);
|
|
444
|
-
} catch (err) {
|
|
445
|
-
setError("Failed to transcribe");
|
|
446
|
-
setRecording(false);
|
|
447
|
-
}
|
|
448
|
-
};
|
|
449
|
-
|
|
450
|
-
return (
|
|
451
|
-
<div>
|
|
452
|
-
<button onClick={recording ? handleStop : handleStart}>
|
|
453
|
-
{recording ? "Stop" : "Start"} Recording
|
|
454
|
-
</button>
|
|
455
|
-
{error && <div className="error">{error}</div>}
|
|
456
|
-
</div>
|
|
457
|
-
);
|
|
458
|
-
}
|
|
459
|
-
```
|
|
31
|
+
## Event Bridge
|
|
460
32
|
|
|
461
|
-
|
|
33
|
+
When connected to the Charivo event bus, the manager emits:
|
|
462
34
|
|
|
463
|
-
|
|
35
|
+
- `stt:start`
|
|
36
|
+
- `stt:stop`
|
|
37
|
+
- `stt:error`
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { STTManager, STTTranscriber, STTOptions } from '@charivo/core';
|
|
1
|
+
import { STTManager, STTTranscriber, CharivoEventEmitter, STTOptions } from '@charivo/core';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* STT Manager - Manages STT session state
|
|
@@ -15,9 +15,7 @@ declare class STTManagerImpl implements STTManager {
|
|
|
15
15
|
/**
|
|
16
16
|
* Set event emitter for STT events
|
|
17
17
|
*/
|
|
18
|
-
setEventEmitter(eventEmitter:
|
|
19
|
-
emit: (event: string, data: any) => void;
|
|
20
|
-
}): void;
|
|
18
|
+
setEventEmitter(eventEmitter: CharivoEventEmitter): void;
|
|
21
19
|
/**
|
|
22
20
|
* Start audio recording (delegates to transcriber)
|
|
23
21
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { STTManager, STTTranscriber, STTOptions } from '@charivo/core';
|
|
1
|
+
import { STTManager, STTTranscriber, CharivoEventEmitter, STTOptions } from '@charivo/core';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* STT Manager - Manages STT session state
|
|
@@ -15,9 +15,7 @@ declare class STTManagerImpl implements STTManager {
|
|
|
15
15
|
/**
|
|
16
16
|
* Set event emitter for STT events
|
|
17
17
|
*/
|
|
18
|
-
setEventEmitter(eventEmitter:
|
|
19
|
-
emit: (event: string, data: any) => void;
|
|
20
|
-
}): void;
|
|
18
|
+
setEventEmitter(eventEmitter: CharivoEventEmitter): void;
|
|
21
19
|
/**
|
|
22
20
|
* Start audio recording (delegates to transcriber)
|
|
23
21
|
*/
|
package/dist/index.js
CHANGED
|
@@ -37,20 +37,16 @@ var STTManagerImpl = class {
|
|
|
37
37
|
* Set event emitter for STT events
|
|
38
38
|
*/
|
|
39
39
|
setEventEmitter(eventEmitter) {
|
|
40
|
-
console.log("\u{1F517} STT Manager: Event emitter connected");
|
|
41
40
|
this.eventEmitter = eventEmitter;
|
|
42
41
|
}
|
|
43
42
|
/**
|
|
44
43
|
* Start audio recording (delegates to transcriber)
|
|
45
44
|
*/
|
|
46
45
|
async start(options) {
|
|
47
|
-
console.log("\u{1F3A4} STT Manager: Starting recording", options);
|
|
48
46
|
this.eventEmitter?.emit("stt:start", { options });
|
|
49
47
|
try {
|
|
50
48
|
await this.sttTranscriber.startRecording(options);
|
|
51
|
-
console.log("\u2705 STT Manager: Recording started");
|
|
52
49
|
} catch (error) {
|
|
53
|
-
console.error("\u274C STT Manager: Recording failed", error);
|
|
54
50
|
this.eventEmitter?.emit("stt:error", { error });
|
|
55
51
|
throw error;
|
|
56
52
|
}
|
|
@@ -59,14 +55,11 @@ var STTManagerImpl = class {
|
|
|
59
55
|
* Stop audio recording and get transcription (delegates to transcriber)
|
|
60
56
|
*/
|
|
61
57
|
async stop() {
|
|
62
|
-
console.log("\u{1F6D1} STT Manager: Stopping recording");
|
|
63
58
|
try {
|
|
64
59
|
const transcription = await this.sttTranscriber.stopRecording();
|
|
65
|
-
console.log("\u2705 STT Manager: Transcription completed", transcription);
|
|
66
60
|
this.eventEmitter?.emit("stt:stop", { transcription });
|
|
67
61
|
return transcription;
|
|
68
62
|
} catch (error) {
|
|
69
|
-
console.error("\u274C STT Manager: Transcription failed", error);
|
|
70
63
|
this.eventEmitter?.emit("stt:error", { error });
|
|
71
64
|
throw error;
|
|
72
65
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -9,20 +9,16 @@ var STTManagerImpl = class {
|
|
|
9
9
|
* Set event emitter for STT events
|
|
10
10
|
*/
|
|
11
11
|
setEventEmitter(eventEmitter) {
|
|
12
|
-
console.log("\u{1F517} STT Manager: Event emitter connected");
|
|
13
12
|
this.eventEmitter = eventEmitter;
|
|
14
13
|
}
|
|
15
14
|
/**
|
|
16
15
|
* Start audio recording (delegates to transcriber)
|
|
17
16
|
*/
|
|
18
17
|
async start(options) {
|
|
19
|
-
console.log("\u{1F3A4} STT Manager: Starting recording", options);
|
|
20
18
|
this.eventEmitter?.emit("stt:start", { options });
|
|
21
19
|
try {
|
|
22
20
|
await this.sttTranscriber.startRecording(options);
|
|
23
|
-
console.log("\u2705 STT Manager: Recording started");
|
|
24
21
|
} catch (error) {
|
|
25
|
-
console.error("\u274C STT Manager: Recording failed", error);
|
|
26
22
|
this.eventEmitter?.emit("stt:error", { error });
|
|
27
23
|
throw error;
|
|
28
24
|
}
|
|
@@ -31,14 +27,11 @@ var STTManagerImpl = class {
|
|
|
31
27
|
* Stop audio recording and get transcription (delegates to transcriber)
|
|
32
28
|
*/
|
|
33
29
|
async stop() {
|
|
34
|
-
console.log("\u{1F6D1} STT Manager: Stopping recording");
|
|
35
30
|
try {
|
|
36
31
|
const transcription = await this.sttTranscriber.stopRecording();
|
|
37
|
-
console.log("\u2705 STT Manager: Transcription completed", transcription);
|
|
38
32
|
this.eventEmitter?.emit("stt:stop", { transcription });
|
|
39
33
|
return transcription;
|
|
40
34
|
} catch (error) {
|
|
41
|
-
console.error("\u274C STT Manager: Transcription failed", error);
|
|
42
35
|
this.eventEmitter?.emit("stt:error", { error });
|
|
43
36
|
throw error;
|
|
44
37
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@charivo/stt-core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "Core STT functionality for Charivo framework",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"transcription"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@charivo/core": "0.0
|
|
23
|
+
"@charivo/core": "0.1.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@charivo/shared": "0.0.
|
|
26
|
+
"@charivo/shared": "0.0.2"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {},
|
|
29
29
|
"files": [
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
"build": "tsup",
|
|
51
51
|
"dev": "tsup --watch",
|
|
52
52
|
"test": "vitest",
|
|
53
|
+
"typecheck": "tsc --noEmit",
|
|
53
54
|
"clean": "rm -rf dist"
|
|
54
55
|
}
|
|
55
56
|
}
|