@pie-players/pie-tts 0.1.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 ADDED
@@ -0,0 +1,111 @@
1
+ # @pie-players/pie-tts
2
+
3
+ TTS interfaces and types for PIE Assessment Toolkit - Pure TypeScript with no UI dependencies.
4
+
5
+ ## Purpose
6
+
7
+ This package provides the foundational interfaces and types for building TTS (Text-to-Speech) providers in the PIE ecosystem. It has **zero dependencies** and no UI framework requirements, making it suitable for:
8
+
9
+ - Implementing custom TTS providers
10
+ - Type-safe TTS integration
11
+ - Framework-agnostic TTS solutions
12
+
13
+ ## What's Included
14
+
15
+ ### Interfaces
16
+
17
+ - **`ITTSProvider`** - Stateless factory for creating TTS implementations
18
+ - **`ITTSProviderImplementation`** - Actual TTS playback implementation
19
+ - **`TTSProviderCapabilities`** - Feature support description
20
+ - **`TTSConfig`** - Provider configuration
21
+
22
+ ### Types
23
+
24
+ - **`TTSFeature`** - Union type of supported features
25
+ - Configuration and capability types
26
+
27
+ ## Installation
28
+
29
+ ```bash
30
+ npm install @pie-players/pie-tts
31
+ # or
32
+ bun add @pie-players/pie-tts
33
+ ```
34
+
35
+ ## Usage
36
+
37
+ ### Implementing a Custom TTS Provider
38
+
39
+ ```typescript
40
+ import type {
41
+ ITTSProvider,
42
+ ITTSProviderImplementation,
43
+ TTSConfig,
44
+ TTSProviderCapabilities,
45
+ TTSFeature
46
+ } from '@pie-players/pie-tts';
47
+
48
+ class MyTTSImplementation implements ITTSProviderImplementation {
49
+ async speak(text: string): Promise<void> {
50
+ // Your implementation
51
+ }
52
+
53
+ pause(): void { /* ... */ }
54
+ resume(): void { /* ... */ }
55
+ stop(): void { /* ... */ }
56
+ isPlaying(): boolean { return false; }
57
+ isPaused(): boolean { return false; }
58
+ }
59
+
60
+ export class MyTTSProvider implements ITTSProvider {
61
+ readonly providerId = 'my-tts';
62
+ readonly providerName = 'My TTS Provider';
63
+ readonly version = '1.0.0';
64
+
65
+ async initialize(config: TTSConfig): Promise<ITTSProviderImplementation> {
66
+ return new MyTTSImplementation(config);
67
+ }
68
+
69
+ supportsFeature(feature: TTSFeature): boolean {
70
+ return feature === 'pause' || feature === 'resume';
71
+ }
72
+
73
+ getCapabilities(): TTSProviderCapabilities {
74
+ return {
75
+ supportsPause: true,
76
+ supportsResume: true,
77
+ supportsWordBoundary: false,
78
+ supportsVoiceSelection: true,
79
+ supportsRateControl: true,
80
+ supportsPitchControl: false,
81
+ };
82
+ }
83
+
84
+ destroy(): void {
85
+ // Cleanup if needed
86
+ }
87
+ }
88
+ ```
89
+
90
+ ## Official Implementations
91
+
92
+ - **Browser TTS** (in `@pie-players/pie-assessment-toolkit`) - Uses Web Speech API, always available as fallback
93
+ - **AWS Polly** (`@pie-players/pie-tts-polly`) - High-quality neural voices with full SSML support
94
+
95
+ ## Design Philosophy
96
+
97
+ This core package intentionally:
98
+ - ✅ Has **zero runtime dependencies**
99
+ - ✅ Contains **only TypeScript interfaces and types**
100
+ - ✅ Is **framework-agnostic** (no React, Svelte, Vue, etc.)
101
+ - ✅ Supports **pluggable architecture**
102
+ - ✅ Enables **type-safe TTS implementations**
103
+
104
+ ## License
105
+
106
+ MIT
107
+
108
+ ## Related Packages
109
+
110
+ - [@pie-players/pie-assessment-toolkit](../assessment-toolkit) - Includes TTSService and BrowserTTSProvider
111
+ - [@pie-players/pie-tts-polly](../tts-polly) - AWS Polly TTS provider
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @pie-players/pie-tts-core
3
+ *
4
+ * Core TTS interfaces and types for PIE Assessment Toolkit.
5
+ * No UI dependencies - pure TypeScript interfaces.
6
+ */
7
+ export type { ITTSProvider, ITTSProviderImplementation, StandardTTSConfig, TTSConfig, TTSConfigExtensions, TTSFeature, TTSProviderCapabilities, } from "./provider-interface";
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,YAAY,EACX,YAAY,EACZ,0BAA0B,EAC1B,iBAAiB,EACjB,SAAS,EACT,mBAAmB,EACnB,UAAU,EACV,uBAAuB,GACvB,MAAM,sBAAsB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @pie-players/pie-tts-core
3
+ *
4
+ * Core TTS interfaces and types for PIE Assessment Toolkit.
5
+ * No UI dependencies - pure TypeScript interfaces.
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
@@ -0,0 +1,208 @@
1
+ /**
2
+ * TTS Provider Interfaces
3
+ *
4
+ * Defines the contract for text-to-speech providers.
5
+ * Providers are stateless factories that create configured TTS implementations.
6
+ *
7
+ * Part of PIE TTS Core - No UI dependencies.
8
+ */
9
+ /**
10
+ * Standard TTS configuration parameters based on W3C Web Speech API.
11
+ *
12
+ * These are portable across all TTS providers (browser, AWS Polly, Google Cloud, etc.)
13
+ * and align with the W3C Web Speech API specification.
14
+ *
15
+ * @see https://w3c.github.io/speech-api/
16
+ */
17
+ export interface StandardTTSConfig {
18
+ /**
19
+ * Voice identifier (provider-specific)
20
+ *
21
+ * @standard W3C Web Speech API (concept)
22
+ * @example "Joanna" (Polly), "en-US-Standard-A" (Google), browser voice name
23
+ */
24
+ voice?: string;
25
+ /**
26
+ * Speech rate (speed multiplier)
27
+ *
28
+ * @standard W3C Web Speech API
29
+ * @range 0.25 to 4.0
30
+ * @default 1.0
31
+ */
32
+ rate?: number;
33
+ /**
34
+ * Pitch adjustment
35
+ *
36
+ * @standard W3C Web Speech API
37
+ * @range 0 to 2 (as multiplier)
38
+ * @default 1.0
39
+ */
40
+ pitch?: number;
41
+ }
42
+ /**
43
+ * Provider-specific extensions for TTS configuration.
44
+ *
45
+ * These are NOT part of W3C standards and support varies by provider.
46
+ */
47
+ export interface TTSConfigExtensions {
48
+ /**
49
+ * Organization/tenant identifier
50
+ *
51
+ * @extension Application-specific
52
+ * @use Multi-tenant applications
53
+ */
54
+ organizationId?: string;
55
+ /**
56
+ * Provider region or endpoint
57
+ *
58
+ * @extension Provider-specific
59
+ * @example "us-east-1" (AWS), "us-central1" (Google Cloud)
60
+ */
61
+ region?: string;
62
+ /**
63
+ * Arbitrary provider-specific options
64
+ *
65
+ * @extension Extensibility point
66
+ * @example { engine: 'neural' } for AWS Polly
67
+ */
68
+ providerOptions?: Record<string, unknown>;
69
+ }
70
+ /**
71
+ * Complete TTS configuration combining standard parameters and extensions.
72
+ *
73
+ * @example Basic usage (portable)
74
+ * ```typescript
75
+ * const config: TTSConfig = {
76
+ * voice: "Joanna",
77
+ * rate: 1.0,
78
+ * pitch: 1.0
79
+ * };
80
+ * ```
81
+ *
82
+ * @example Advanced usage with extensions
83
+ * ```typescript
84
+ * const config: TTSConfig = {
85
+ * voice: "Joanna",
86
+ * rate: 1.0,
87
+ * // Extensions
88
+ * region: "us-east-1",
89
+ * organizationId: "acme-corp",
90
+ * providerOptions: { engine: "neural" }
91
+ * };
92
+ * ```
93
+ */
94
+ export interface TTSConfig extends StandardTTSConfig, TTSConfigExtensions {
95
+ }
96
+ /**
97
+ * TTS Provider interface
98
+ *
99
+ * Providers are stateless factories that create TTS implementations.
100
+ * They describe capabilities and create configured instances.
101
+ */
102
+ export interface ITTSProvider {
103
+ /**
104
+ * Unique identifier for this provider
105
+ */
106
+ readonly providerId: string;
107
+ /**
108
+ * Human-readable provider name
109
+ */
110
+ readonly providerName: string;
111
+ /**
112
+ * Provider version
113
+ */
114
+ readonly version: string;
115
+ /**
116
+ * Initialize and create a configured TTS implementation
117
+ */
118
+ initialize(config: TTSConfig): Promise<ITTSProviderImplementation>;
119
+ /**
120
+ * Check if a specific feature is supported
121
+ */
122
+ supportsFeature(feature: TTSFeature): boolean;
123
+ /**
124
+ * Get provider capabilities
125
+ */
126
+ getCapabilities(): TTSProviderCapabilities;
127
+ /**
128
+ * Clean up provider resources
129
+ */
130
+ destroy(): void;
131
+ }
132
+ /**
133
+ * TTS Provider Implementation interface
134
+ *
135
+ * The actual TTS implementation that handles playback.
136
+ * Created by ITTSProvider.initialize()
137
+ */
138
+ export interface ITTSProviderImplementation {
139
+ /**
140
+ * Speak text
141
+ */
142
+ speak(text: string): Promise<void>;
143
+ /**
144
+ * Pause playback
145
+ */
146
+ pause(): void;
147
+ /**
148
+ * Resume playback
149
+ */
150
+ resume(): void;
151
+ /**
152
+ * Stop playback
153
+ */
154
+ stop(): void;
155
+ /**
156
+ * Check if currently playing
157
+ */
158
+ isPlaying(): boolean;
159
+ /**
160
+ * Check if paused
161
+ */
162
+ isPaused(): boolean;
163
+ /**
164
+ * Word boundary callback (optional)
165
+ * Called during speech for word highlighting
166
+ */
167
+ onWordBoundary?: (word: string, position: number) => void;
168
+ }
169
+ /**
170
+ * TTS Provider capabilities
171
+ *
172
+ * Describes which features a provider supports
173
+ */
174
+ export interface TTSProviderCapabilities {
175
+ /**
176
+ * Supports pause/resume
177
+ */
178
+ supportsPause: boolean;
179
+ /**
180
+ * Supports resume after pause
181
+ */
182
+ supportsResume: boolean;
183
+ /**
184
+ * Supports word boundary events for highlighting
185
+ */
186
+ supportsWordBoundary: boolean;
187
+ /**
188
+ * Supports voice selection
189
+ */
190
+ supportsVoiceSelection: boolean;
191
+ /**
192
+ * Supports rate control (speed)
193
+ */
194
+ supportsRateControl: boolean;
195
+ /**
196
+ * Supports pitch control
197
+ */
198
+ supportsPitchControl: boolean;
199
+ /**
200
+ * Maximum text length (if limited)
201
+ */
202
+ maxTextLength?: number;
203
+ }
204
+ /**
205
+ * TTS features for capability checking
206
+ */
207
+ export type TTSFeature = "pause" | "resume" | "wordBoundary" | "voiceSelection" | "rateControl" | "pitchControl";
208
+ //# sourceMappingURL=provider-interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-interface.d.ts","sourceRoot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OAEG;IACH,MAAM,IAAI,IAAI,CAAC;IAEf;;OAEG;IACH,IAAI,IAAI,IAAI,CAAC;IAEb;;OAEG;IACH,SAAS,IAAI,OAAO,CAAC;IAErB;;OAEG;IACH,QAAQ,IAAI,OAAO,CAAC;IAEpB;;;OAGG;IACH,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1D;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACvC;;OAEG;IACH,aAAa,EAAE,OAAO,CAAC;IAEvB;;OAEG;IACH,cAAc,EAAE,OAAO,CAAC;IAExB;;OAEG;IACH,oBAAoB,EAAE,OAAO,CAAC;IAE9B;;OAEG;IACH,sBAAsB,EAAE,OAAO,CAAC;IAEhC;;OAEG;IACH,mBAAmB,EAAE,OAAO,CAAC;IAE7B;;OAEG;IACH,oBAAoB,EAAE,OAAO,CAAC;IAE9B;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,MAAM,UAAU,GACnB,OAAO,GACP,QAAQ,GACR,cAAc,GACd,gBAAgB,GAChB,aAAa,GACb,cAAc,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * TTS Provider Interfaces
3
+ *
4
+ * Defines the contract for text-to-speech providers.
5
+ * Providers are stateless factories that create configured TTS implementations.
6
+ *
7
+ * Part of PIE TTS Core - No UI dependencies.
8
+ */
9
+ export {};
10
+ //# sourceMappingURL=provider-interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-interface.js","sourceRoot":"","sources":["../src/provider-interface.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@pie-players/pie-tts",
3
+ "version": "0.1.0",
4
+ "description": "TTS interfaces and types for PIE Assessment Toolkit - No UI dependencies",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "README.md"
17
+ ],
18
+ "scripts": {
19
+ "build": "tsc",
20
+ "typecheck": "tsc --noEmit"
21
+ },
22
+ "keywords": [
23
+ "pie",
24
+ "tts",
25
+ "text-to-speech",
26
+ "interfaces",
27
+ "accessibility"
28
+ ],
29
+ "author": "PIE Framework",
30
+ "license": "MIT",
31
+ "devDependencies": {
32
+ "typescript": "^5.7.2"
33
+ }
34
+ }