@pie-players/pie-assessment-toolkit 0.3.74 → 1.0.0-beta.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 +658 -714
- package/custom-elements.json +1315 -0
- package/dist/attempt/TestSession.d.ts +1 -21
- package/dist/attempt/TestSession.js +16 -102
- package/dist/components/ItemScope.custom-element.d.ts +1 -0
- package/dist/components/ItemScope.custom-element.js +1 -0
- package/dist/components/ItemToolBar.custom-element.js +1 -1
- package/dist/components/PieAssessmentToolkit.custom-element.js +14 -14
- package/dist/components/SectionToolBar.custom-element.js +1 -1
- package/dist/components/chunks/ItemToolBar-3zrc4p3d.js +4 -0
- package/dist/components/chunks/ItemToolBar-66hcwmfw.js +2 -0
- package/dist/components/chunks/ItemToolBar-9gqhfxtn.js +40 -0
- package/dist/components/chunks/ItemToolBar-hzc5wyjp.js +2 -0
- package/dist/components/chunks/{ItemToolBar-gmrryv2v.js → ItemToolBar-kkj69ptr.js} +1 -1
- package/dist/components/chunks/ItemToolBar-vdkyn9f3.js +2 -0
- package/dist/components/chunks/sre-engine-bj997w4b.js +1 -0
- package/dist/components/item-scope-element.d.ts +2 -0
- package/dist/components/item-scope-element.js +2 -0
- package/dist/context/assessment-toolkit-context.d.ts +33 -6
- package/dist/index.d.ts +25 -50
- package/dist/index.js +15 -45
- package/dist/policy/core/PolicySource.d.ts +2 -2
- package/dist/policy/core/ToolPolicyEngine.d.ts +118 -34
- package/dist/policy/core/ToolPolicyEngine.js +203 -56
- package/dist/policy/core/compose-decision.d.ts +28 -7
- package/dist/policy/core/compose-decision.js +95 -74
- package/dist/policy/core/decision-types.d.ts +98 -55
- package/dist/policy/core/feature-decision.d.ts +28 -19
- package/dist/policy/core/feature-decision.js +15 -11
- package/dist/policy/core/pnp-policy-inputs.d.ts +29 -35
- package/dist/policy/core/pnp-policy-inputs.js +40 -88
- package/dist/policy/core/provenance.d.ts +10 -5
- package/dist/policy/core/provenance.js +1 -1
- package/dist/policy/core/tool-parameters.d.ts +11 -0
- package/dist/policy/core/tool-parameters.js +15 -0
- package/dist/policy/engine.d.ts +7 -23
- package/dist/policy/engine.js +5 -20
- package/dist/policy/sources/PnpPolicySource.d.ts +43 -68
- package/dist/policy/sources/PnpPolicySource.js +133 -132
- package/dist/runtime/SectionControllerBinding.d.ts +283 -0
- package/dist/runtime/SectionControllerBinding.js +456 -0
- package/dist/runtime/SectionRuntimeEngine.d.ts +26 -289
- package/dist/runtime/SectionRuntimeEngine.js +30 -372
- package/dist/runtime/adapter/SectionEngineAdapter.d.ts +19 -80
- package/dist/runtime/adapter/SectionEngineAdapter.js +19 -92
- package/dist/runtime/adapter/dom-event-bridge.d.ts +15 -30
- package/dist/runtime/adapter/dom-event-bridge.js +17 -44
- package/dist/runtime/adapter/subscriber-fanout.d.ts +1 -3
- package/dist/runtime/adapter/subscriber-fanout.js +2 -6
- package/dist/runtime/catalog-context.d.ts +19 -0
- package/dist/runtime/catalog-context.js +28 -0
- package/dist/runtime/composition-emit-scheduler.d.ts +12 -18
- package/dist/runtime/composition-emit-scheduler.js +10 -16
- package/dist/runtime/content-language.d.ts +32 -0
- package/dist/runtime/content-language.js +46 -0
- package/dist/runtime/content-region.d.ts +13 -0
- package/dist/runtime/content-region.js +29 -0
- package/dist/runtime/content-registration.d.ts +13 -0
- package/dist/runtime/content-registration.js +25 -0
- package/dist/runtime/core/SectionEngineCore.d.ts +2 -4
- package/dist/runtime/core/SectionEngineCore.js +2 -6
- package/dist/runtime/core/cohort.d.ts +1 -6
- package/dist/runtime/core/cohort.js +1 -10
- package/dist/runtime/core/engine-input.d.ts +18 -30
- package/dist/runtime/core/engine-input.js +11 -12
- package/dist/runtime/core/engine-output.d.ts +17 -40
- package/dist/runtime/core/engine-output.js +9 -21
- package/dist/runtime/core/engine-readiness.d.ts +5 -37
- package/dist/runtime/core/engine-readiness.js +8 -41
- package/dist/runtime/core/engine-resolver.d.ts +46 -74
- package/dist/runtime/core/engine-resolver.js +18 -43
- package/dist/runtime/core/engine-state.d.ts +28 -36
- package/dist/runtime/core/engine-state.js +18 -21
- package/dist/runtime/core/engine-transition.d.ts +14 -19
- package/dist/runtime/core/engine-transition.js +74 -53
- package/dist/runtime/engine.d.ts +16 -19
- package/dist/runtime/engine.js +12 -19
- package/dist/runtime/page-warnings.d.ts +13 -0
- package/dist/runtime/page-warnings.js +22 -0
- package/dist/runtime/policy-input-forwarding.d.ts +25 -0
- package/dist/runtime/policy-input-forwarding.js +25 -0
- package/dist/runtime/registration-events.d.ts +22 -14
- package/dist/runtime/runtime-event-claim.d.ts +8 -0
- package/dist/runtime/runtime-event-claim.js +15 -0
- package/dist/runtime/runtime-id.d.ts +1 -1
- package/dist/runtime/runtime-id.js +1 -1
- package/dist/runtime/shell-event-bridge.d.ts +45 -0
- package/dist/runtime/shell-event-bridge.js +127 -0
- package/dist/runtime/shell-registration.d.ts +73 -0
- package/dist/runtime/shell-registration.js +95 -0
- package/dist/runtime/shell-scope.d.ts +68 -0
- package/dist/runtime/shell-scope.js +194 -0
- package/dist/runtime/tool-host-contract.d.ts +8 -14
- package/dist/runtime/tool-host-contract.js +12 -12
- package/dist/runtime/unclaimed-registration-watch.d.ts +7 -0
- package/dist/runtime/unclaimed-registration-watch.js +23 -0
- package/dist/services/AccessibilityCatalogResolver.d.ts +21 -31
- package/dist/services/AccessibilityCatalogResolver.js +29 -42
- package/dist/services/ElementToolStateStore.d.ts +42 -67
- package/dist/services/ElementToolStateStore.js +65 -71
- package/dist/services/HighlightCoordinator.d.ts +28 -40
- package/dist/services/HighlightCoordinator.js +459 -381
- package/dist/services/RangeSerializer.d.ts +11 -33
- package/dist/services/RangeSerializer.js +88 -59
- package/dist/services/SSMLExtractor.d.ts +8 -31
- package/dist/services/SSMLExtractor.js +18 -40
- package/dist/services/TTSService.d.ts +159 -119
- package/dist/services/TTSService.js +937 -822
- package/dist/services/ToolCoordinator.d.ts +42 -102
- package/dist/services/ToolCoordinator.js +178 -256
- package/dist/services/ToolRegistry.d.ts +152 -133
- package/dist/services/ToolRegistry.js +192 -178
- package/dist/services/ToolkitCoordinator.d.ts +233 -237
- package/dist/services/ToolkitCoordinator.js +615 -557
- package/dist/services/audio-handoff.d.ts +6 -7
- package/dist/services/audio-handoff.js +20 -14
- package/dist/services/catalog-owner.d.ts +0 -1
- package/dist/services/framework-error-bus.d.ts +3 -6
- package/dist/services/framework-error-bus.js +3 -6
- package/dist/services/framework-error.d.ts +51 -13
- package/dist/services/framework-error.js +19 -20
- package/dist/services/interfaces.d.ts +189 -184
- package/dist/services/section-controller-types.d.ts +7 -7
- package/dist/services/section-session-assignment.d.ts +21 -0
- package/dist/services/section-session-assignment.js +80 -0
- package/dist/services/spoken-audio-cards.d.ts +2 -6
- package/dist/services/spoken-audio-cards.js +2 -6
- package/dist/services/tool-config-defaults.d.ts +3 -3
- package/dist/services/tool-config-defaults.js +3 -3
- package/dist/services/tool-config-validation.d.ts +9 -12
- package/dist/services/tool-config-validation.js +47 -87
- package/dist/services/tool-context.d.ts +7 -31
- package/dist/services/tool-context.js +99 -65
- package/dist/services/tool-failure.d.ts +30 -0
- package/dist/services/tool-failure.js +11 -0
- package/dist/services/tool-icons.d.ts +5 -5
- package/dist/services/tool-icons.js +6 -5
- package/dist/services/tool-instance-id.d.ts +8 -7
- package/dist/services/tool-instance-id.js +12 -24
- package/dist/services/tool-providers/TTSToolProvider.d.ts +20 -58
- package/dist/services/tool-providers/TTSToolProvider.js +32 -85
- package/dist/services/tool-providers/ToolProviderApi.d.ts +10 -11
- package/dist/services/tool-providers/ToolProviderRegistry.d.ts +29 -60
- package/dist/services/tool-providers/ToolProviderRegistry.js +128 -144
- package/dist/services/tool-request.d.ts +31 -12
- package/dist/services/tool-request.js +31 -16
- package/dist/services/toolbar-decided-tools.d.ts +16 -0
- package/dist/services/toolbar-decided-tools.js +29 -0
- package/dist/services/toolbar-items.js +2 -5
- package/dist/services/tools-config-normalizer.d.ts +33 -29
- package/dist/services/tools-config-normalizer.js +26 -28
- package/dist/services/tts/browser-provider.d.ts +39 -6
- package/dist/services/tts/browser-provider.js +280 -160
- package/dist/services/tts/catalog-span-alignment.js +14 -7
- package/dist/services/tts/flat-tree.d.ts +64 -0
- package/dist/services/tts/flat-tree.js +269 -0
- package/dist/services/tts/generated-speech/assemble-plan.d.ts +3 -1
- package/dist/services/tts/generated-speech/assemble-plan.js +3 -1
- package/dist/services/tts/generated-speech/dom/build-dom-plan.d.ts +2 -0
- package/dist/services/tts/generated-speech/dom/build-dom-plan.js +1 -1
- package/dist/services/tts/generated-speech/dom/to-chunk-inputs.d.ts +2 -2
- package/dist/services/tts/generated-speech/index.d.ts +1 -1
- package/dist/services/tts/generated-speech/index.js +1 -1
- package/dist/services/tts/generated-speech/math-speech-cache.d.ts +3 -1
- package/dist/services/tts/generated-speech/math-speech-cache.js +5 -1
- package/dist/services/tts/generated-speech/types.d.ts +1 -1
- package/dist/services/tts/generated-speech/types.js +1 -1
- package/dist/services/tts/highlight-pipeline/create-highlight-plan.js +22 -16
- package/dist/services/tts/highlight-pipeline/prose-boundary-resolver.js +6 -4
- package/dist/services/tts/highlight-pipeline/readable-region.js +3 -2
- package/dist/services/tts/highlight-pipeline/types.d.ts +5 -0
- package/dist/services/tts/highlight-pipeline/visible-map-range.d.ts +12 -0
- package/dist/services/tts/highlight-pipeline/visible-map-range.js +73 -7
- package/dist/services/tts/highlight-target-resolver.d.ts +12 -0
- package/dist/services/tts/math-aware-text-processing.d.ts +5 -1
- package/dist/services/tts/math-aware-text-processing.js +42 -47
- package/dist/services/tts/math-control-names.d.ts +21 -0
- package/dist/services/tts/math-control-names.js +142 -0
- package/dist/services/tts/math-speech.d.ts +12 -1
- package/dist/services/tts/math-speech.js +54 -18
- package/dist/services/tts/mathml-sanitization.d.ts +7 -0
- package/dist/services/tts/mathml-sanitization.js +9 -1
- package/dist/services/tts/provider-options.d.ts +52 -0
- package/dist/services/tts/provider-options.js +1 -0
- package/dist/services/tts/ssml/spoken-text.d.ts +2 -26
- package/dist/services/tts/ssml/spoken-text.js +29 -0
- package/dist/services/tts/start-failure.d.ts +4 -0
- package/dist/services/tts/start-failure.js +19 -0
- package/dist/services/tts/text-processing.d.ts +9 -0
- package/dist/services/tts/text-processing.js +46 -33
- package/dist/services/tts/text-segmentation.d.ts +12 -0
- package/dist/services/tts/text-segmentation.js +60 -10
- package/dist/services/tts-runtime-config.d.ts +54 -26
- package/dist/services/tts-runtime-config.js +27 -112
- package/dist/tools/content-capability-resolution.d.ts +9 -11
- package/dist/tools/content-capability-resolution.js +8 -45
- package/dist/tools/registration.d.ts +59 -0
- package/dist/tools/registration.js +55 -0
- package/dist/tools/registrations/toolbar-registration-helpers.d.ts +6 -0
- package/dist/tools/registrations/toolbar-registration-helpers.js +8 -2
- package/dist/tools/tool-surface-host.d.ts +6 -10
- package/dist/tools/tool-surface-host.js +45 -50
- package/dist/tools/tool-tag-map.d.ts +5 -15
- package/dist/tools/tool-tag-map.js +6 -20
- package/dist/utils/structural-equality.d.ts +11 -0
- package/dist/utils/structural-equality.js +47 -0
- package/package.json +15 -29
- package/dist/attempt/adapters/activity-to-test-attempt-session.d.ts +0 -49
- package/dist/attempt/adapters/activity-to-test-attempt-session.js +0 -138
- package/dist/components/chunks/ItemToolBar-b9dz5jvd.js +0 -40
- package/dist/components/chunks/ItemToolBar-h4xap0t0.js +0 -4
- package/dist/components/chunks/ItemToolBar-wr2myaah.js +0 -2
- package/dist/components/chunks/sre-engine-wf9s43gg.js +0 -1
- package/dist/context/runtime-context-consumer.d.ts +0 -13
- package/dist/context/runtime-context-consumer.js +0 -18
- package/dist/item-loader.d.ts +0 -44
- package/dist/item-loader.js +0 -61
- package/dist/policy/core/engine-context.d.ts +0 -29
- package/dist/policy/core/engine-context.js +0 -27
- package/dist/policy/core/policy-source-tag.d.ts +0 -31
- package/dist/policy/core/policy-source-tag.js +0 -28
- package/dist/policy/internal.d.ts +0 -25
- package/dist/policy/internal.js +0 -25
- package/dist/runtime/adapter/coordinator-bridge.d.ts +0 -92
- package/dist/runtime/adapter/coordinator-bridge.js +0 -126
- package/dist/runtime/adapter/framework-error-bridge.d.ts +0 -36
- package/dist/runtime/adapter/framework-error-bridge.js +0 -46
- package/dist/runtime/adapter/instrumentation-bridge.d.ts +0 -31
- package/dist/runtime/adapter/instrumentation-bridge.js +0 -38
- package/dist/runtime/core/engine-stage-derivation.d.ts +0 -18
- package/dist/runtime/core/engine-stage-derivation.js +0 -29
- package/dist/runtime/engine-context.d.ts +0 -39
- package/dist/runtime/engine-context.js +0 -31
- package/dist/runtime/internal.d.ts +0 -43
- package/dist/runtime/internal.js +0 -45
- package/dist/runtime/section-runtime-engine-host-context.d.ts +0 -74
- package/dist/runtime/section-runtime-engine-host-context.js +0 -57
- package/dist/runtime/stage-emit-gate.d.ts +0 -92
- package/dist/runtime/stage-emit-gate.js +0 -82
- package/dist/services/ContextVariableStore.d.ts +0 -113
- package/dist/services/ContextVariableStore.js +0 -206
- package/dist/services/I18nService.d.ts +0 -47
- package/dist/services/I18nService.js +0 -84
- package/dist/services/ThemeProvider.d.ts +0 -95
- package/dist/services/ThemeProvider.js +0 -334
- package/dist/services/defaultPersonalNeedsProfile.d.ts +0 -21
- package/dist/services/defaultPersonalNeedsProfile.js +0 -26
- package/dist/services/pnp-standard-features.d.ts +0 -238
- package/dist/services/pnp-standard-features.js +0 -338
- package/dist/services/tts-control-events.d.ts +0 -13
- package/dist/services/tts-control-events.js +0 -7
- package/dist/tools/client.d.ts +0 -10
- package/dist/tools/client.js +0 -10
- package/dist/tools/internal.d.ts +0 -44
- package/dist/tools/internal.js +0 -39
- package/dist/utils/logger.d.ts +0 -6
- package/dist/utils/logger.js +0 -10
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* TTSService
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* and integrates with HighlightCoordinator for word highlighting.
|
|
4
|
+
* Owns one read-aloud session: the installed provider, playback state, and the
|
|
5
|
+
* word and sentence highlights painted through HighlightCoordinator.
|
|
7
6
|
*
|
|
8
|
-
*
|
|
9
|
-
* -
|
|
10
|
-
*
|
|
11
|
-
* -
|
|
12
|
-
*
|
|
13
|
-
* -
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
7
|
+
* Layout:
|
|
8
|
+
* - Provider and host wiring: initialize, setCatalogResolver, the highlight
|
|
9
|
+
* target resolver and math-speech sources.
|
|
10
|
+
* - Content resolution: catalog spoken card, then catalog-composed chunks
|
|
11
|
+
* (script and/or recording with a plain fallback), then generated speech.
|
|
12
|
+
* - Speech plan: structural pauses, seek segments, sentence segments and the
|
|
13
|
+
* normalized-to-DOM position map.
|
|
14
|
+
* - Playback: speakContent → executeSpeakPlayback, the run guard (speakRunId,
|
|
15
|
+
* runOwner), the pause hold and the playback-start barrier.
|
|
16
|
+
* - Highlight painting: boundary handling, the host resolver remap, catalog
|
|
17
|
+
* highlight plans.
|
|
18
|
+
* - Controls and state: pause/resume/stop/seek/rate, setState and listeners.
|
|
17
19
|
*/
|
|
18
|
-
import type { ITTSProvider, TTSConfig
|
|
19
|
-
import type { AccessibilityCatalogResolver
|
|
20
|
-
import type { HighlightCoordinatorApi } from "./interfaces.js";
|
|
20
|
+
import type { ITTSProvider, TTSConfig } from "@pie-players/pie-tts";
|
|
21
|
+
import type { AccessibilityCatalogResolver } from "./AccessibilityCatalogResolver.js";
|
|
22
|
+
import type { HighlightCoordinatorApi, SpeakOptions } from "./interfaces.js";
|
|
21
23
|
import type { TTSHighlightTargetResolverProvider } from "./tts/highlight-target-resolver.js";
|
|
22
|
-
|
|
24
|
+
import { type SREMathSpeechOptions } from "./tts/math-speech.js";
|
|
25
|
+
import type { ToolkitTTSConfig } from "./tts/provider-options.js";
|
|
23
26
|
/**
|
|
24
27
|
* Playback state
|
|
25
28
|
*/
|
|
@@ -30,19 +33,7 @@ export declare enum PlaybackState {
|
|
|
30
33
|
PAUSED = "paused",
|
|
31
34
|
ERROR = "error"
|
|
32
35
|
}
|
|
33
|
-
type HighlightMode = "word" | "sentence";
|
|
34
|
-
interface SpeakOptions {
|
|
35
|
-
catalogId?: string;
|
|
36
|
-
catalogContext?: CatalogLookupContext;
|
|
37
|
-
ignoreCatalogs?: boolean;
|
|
38
|
-
language?: string;
|
|
39
|
-
contentElement?: Element;
|
|
40
|
-
wordBoundaryOffset?: number;
|
|
41
|
-
highlightModeOverride?: HighlightMode;
|
|
42
|
-
}
|
|
43
36
|
/**
|
|
44
|
-
* TTSService
|
|
45
|
-
*
|
|
46
37
|
* Instantiable service for text-to-speech functionality.
|
|
47
38
|
* Each instance manages its own playback state.
|
|
48
39
|
*/
|
|
@@ -53,13 +44,20 @@ export declare class TTSService {
|
|
|
53
44
|
private highlightTargetResolverProvider;
|
|
54
45
|
private catalogResolver;
|
|
55
46
|
private state;
|
|
47
|
+
private resumeState;
|
|
56
48
|
private ttsConfig;
|
|
49
|
+
private hostLocales;
|
|
50
|
+
private readLocale;
|
|
51
|
+
private disposed;
|
|
52
|
+
private readinessGate;
|
|
53
|
+
private mathSpeechSource;
|
|
57
54
|
private currentText;
|
|
58
55
|
private currentContentElement;
|
|
59
56
|
private normalizedToDOM;
|
|
60
57
|
private listeners;
|
|
61
58
|
private lastError;
|
|
62
59
|
private speakRunId;
|
|
60
|
+
private runOwner;
|
|
63
61
|
private currentBoundaryOffset;
|
|
64
62
|
private activeWordBoundaryOffset;
|
|
65
63
|
private seekSegments;
|
|
@@ -70,42 +68,80 @@ export declare class TTSService {
|
|
|
70
68
|
private playbackStartDeferredRunId;
|
|
71
69
|
private pendingPlaybackStartHighlights;
|
|
72
70
|
private playbackStartBarrierCleanup;
|
|
71
|
+
private pauseHold;
|
|
72
|
+
private structuralPause;
|
|
73
73
|
private playbackRateWriteQueue;
|
|
74
74
|
private playbackRateRequestId;
|
|
75
75
|
private pendingPlaybackRateRequest;
|
|
76
76
|
private activePlaybackRate;
|
|
77
77
|
private activeHighlightMode;
|
|
78
|
+
private wordlessPartHighlight;
|
|
78
79
|
private lastRenderedRegionTarget;
|
|
79
80
|
private telemetryReporter;
|
|
80
81
|
private readonly generatedMathSpeechResolver;
|
|
81
|
-
private static readonly debugEnabled;
|
|
82
|
-
constructor();
|
|
83
|
-
private debugLog;
|
|
84
82
|
private clearPlaybackStartBarrier;
|
|
85
83
|
private notifyPlaybackStarted;
|
|
84
|
+
/**
|
|
85
|
+
* A word-mode part whose playback sends no boundaries, such as a server
|
|
86
|
+
* response without speech marks, highlights as a sentence-mode read does.
|
|
87
|
+
* Catalog chunks and a single speak highlight the same in both modes.
|
|
88
|
+
*/
|
|
89
|
+
private highlightWordlessPlayback;
|
|
90
|
+
/**
|
|
91
|
+
* Defers marking the run playing, and the highlights queued through
|
|
92
|
+
* runWhenPlaybackStarts, until the provider or the recording signals that
|
|
93
|
+
* audio started. Returns the barrier's cleanup, or null when nothing will
|
|
94
|
+
* signal a start, in which case the caller marks the run playing itself.
|
|
95
|
+
*/
|
|
86
96
|
private installPlaybackStartBarrier;
|
|
87
97
|
private runWhenPlaybackStarts;
|
|
98
|
+
/** Resolves when run `runId` may start its next part: at once unless paused. */
|
|
99
|
+
private waitWhilePaused;
|
|
100
|
+
private releasePauseHold;
|
|
101
|
+
private waitStructuralPause;
|
|
102
|
+
private cancelStructuralPause;
|
|
103
|
+
/**
|
|
104
|
+
* Release what a superseded run still holds: its start barrier, a recorded
|
|
105
|
+
* clip still playing, a structural gap and a pause hold. Its loops then see
|
|
106
|
+
* the new run id and return.
|
|
107
|
+
*/
|
|
108
|
+
private abandonRun;
|
|
109
|
+
/**
|
|
110
|
+
* Start a run and enter loading. From here a pause or stop applies to the
|
|
111
|
+
* run, whatever it is still waiting for: the provider, its content or the
|
|
112
|
+
* provider's audio.
|
|
113
|
+
*/
|
|
114
|
+
private beginRun;
|
|
115
|
+
/** The run's audio is sounding; under a pause, it sounds again on resume. */
|
|
116
|
+
private markPlaying;
|
|
117
|
+
private assertNotDisposed;
|
|
88
118
|
private emitTelemetry;
|
|
89
119
|
/**
|
|
90
120
|
* Initialize TTS service with a provider
|
|
91
|
-
*
|
|
92
|
-
* @param provider TTS provider instance
|
|
93
|
-
* @param config Provider configuration
|
|
94
121
|
*/
|
|
95
|
-
initialize(provider: ITTSProvider, config?: Partial<
|
|
122
|
+
initialize(provider: ITTSProvider, config?: Partial<ToolkitTTSConfig>): Promise<void>;
|
|
96
123
|
/**
|
|
97
|
-
* Update
|
|
98
|
-
*
|
|
99
|
-
* This allows changing rate, pitch, and voice on the fly.
|
|
100
|
-
* Note: Some providers may require reinitialization for voice changes.
|
|
101
|
-
*
|
|
102
|
-
* @param settings Partial settings to update (rate, pitch, voice)
|
|
124
|
+
* Update rate, pitch, voice or provider options without reinitializing.
|
|
125
|
+
* `providerOptions` merge over the ones already configured.
|
|
103
126
|
*/
|
|
104
127
|
updateSettings(settings: Partial<TTSConfig>): Promise<void>;
|
|
105
128
|
/**
|
|
106
129
|
* Set highlight coordinator for word highlighting
|
|
107
130
|
*/
|
|
108
131
|
setHighlightCoordinator(coordinator: HighlightCoordinatorApi): void;
|
|
132
|
+
/**
|
|
133
|
+
* Starts the service when a caller speaks before it is initialized; a gate
|
|
134
|
+
* that rejects fails the speak with its error. The coordinator installs one
|
|
135
|
+
* that runs its own text-to-speech start.
|
|
136
|
+
*/
|
|
137
|
+
setReadinessGate(gate: (() => Promise<void>) | null): void;
|
|
138
|
+
/**
|
|
139
|
+
* Where the configured math speech options come from before, and apart from,
|
|
140
|
+
* initialization, so math names do not depend on when speech started.
|
|
141
|
+
*/
|
|
142
|
+
setMathSpeechSource(source: (() => unknown) | null): void;
|
|
143
|
+
/** The start a speak must wait for, or null when it can speak now without yielding. */
|
|
144
|
+
private pendingReadiness;
|
|
109
145
|
/**
|
|
110
146
|
* Set a late-bound provider for optional host TTS highlight target remapping.
|
|
111
147
|
*
|
|
@@ -127,22 +163,8 @@ export declare class TTSService {
|
|
|
127
163
|
*
|
|
128
164
|
* When set, the speak() method will check for pre-authored spoken
|
|
129
165
|
* content in catalogs before falling back to generated TTS.
|
|
130
|
-
*
|
|
131
|
-
* @param resolver AccessibilityCatalogResolver instance
|
|
132
166
|
*/
|
|
133
167
|
setCatalogResolver(resolver: AccessibilityCatalogResolver): void;
|
|
134
|
-
/**
|
|
135
|
-
* Whether a catalog holds spoken content this service could actually speak.
|
|
136
|
-
*
|
|
137
|
-
* Exists because `data-catalog-idref` is one attribute with several readers:
|
|
138
|
-
* a node can be docked to a catalog that carries only a signing card, and the
|
|
139
|
-
* nearest docked ancestor of a selection is therefore not necessarily the one
|
|
140
|
-
* holding its authored SSML. A caller resolving a selection climbs ancestors
|
|
141
|
-
* and asks this before settling on an id — see the TTS tool's
|
|
142
|
-
* `findSpokenCatalogId`. Without it, a signing card docked on an inner node
|
|
143
|
-
* silently shadows authored speech on an outer one.
|
|
144
|
-
*/
|
|
145
|
-
hasSpokenAlternate(catalogId: string, language?: string): boolean;
|
|
146
168
|
private getHighlightResolverRuntime;
|
|
147
169
|
private getNodeElement;
|
|
148
170
|
private isElementWithinScope;
|
|
@@ -150,24 +172,50 @@ export declare class TTSService {
|
|
|
150
172
|
private resolveWordHighlightRange;
|
|
151
173
|
private resolveSentenceHighlightTargets;
|
|
152
174
|
private createTextRange;
|
|
153
|
-
|
|
175
|
+
/**
|
|
176
|
+
* Paint the spoken word, each range offered to the host's resolver. A word
|
|
177
|
+
* split across inline elements is one range over its text nodes; across
|
|
178
|
+
* shadow trees, one range per tree.
|
|
179
|
+
*/
|
|
180
|
+
private paintTTSWord;
|
|
154
181
|
private paintTTSSentenceRanges;
|
|
182
|
+
private providerOptions;
|
|
183
|
+
/** The longest text the provider accepts in one speak, when it declares one. */
|
|
184
|
+
private maxTextLength;
|
|
155
185
|
/**
|
|
156
|
-
*
|
|
186
|
+
* Speak `text`, in pieces when it exceeds the provider's `maxTextLength`. Word
|
|
187
|
+
* boundaries keep indexing the whole text. An SSML document cannot be cut, so
|
|
188
|
+
* one over the limit fails and the chunk's plain fallback reads instead.
|
|
157
189
|
*/
|
|
158
|
-
|
|
190
|
+
private speakWithinLimit;
|
|
191
|
+
/** Segments no longer than the provider's `maxTextLength`, offsets kept. */
|
|
192
|
+
private segmentsWithinLimit;
|
|
159
193
|
/**
|
|
160
|
-
*
|
|
161
|
-
*
|
|
194
|
+
* Text-collection options for `locale`, with the provider's boundary-spacing
|
|
195
|
+
* mode when it names a known one.
|
|
162
196
|
*/
|
|
163
197
|
private getTextProcessingOptions;
|
|
164
|
-
|
|
198
|
+
/**
|
|
199
|
+
* The language a read of `node` is in. Its content language is the nearest
|
|
200
|
+
* `lang` between it and its shell, else the language the speak names, else a
|
|
201
|
+
* pinned `lang_id`. Its locale is that content language, else the host's
|
|
202
|
+
* configured locale, else en-US.
|
|
203
|
+
*/
|
|
204
|
+
private resolveReadLanguage;
|
|
205
|
+
/**
|
|
206
|
+
* The host's SRE options for math speech: from the installed source, else as
|
|
207
|
+
* this service was initialized with.
|
|
208
|
+
*/
|
|
209
|
+
getMathSpeechOptions(): SREMathSpeechOptions | undefined;
|
|
210
|
+
/**
|
|
211
|
+
* Rebuilds normalizedToDOM from `element`'s visible text; traced runs also
|
|
212
|
+
* log how it differs from `spokenText`.
|
|
213
|
+
*/
|
|
165
214
|
private buildPositionMap;
|
|
166
215
|
private getStructuralPauseProfile;
|
|
167
216
|
private resolvePauseMsFromUnits;
|
|
168
217
|
private resolveHighlightMode;
|
|
169
218
|
private hasExplicitBreakSemantics;
|
|
170
|
-
private isElementHidden;
|
|
171
219
|
private getBoundaryStrength;
|
|
172
220
|
private getBoundaryAnchor;
|
|
173
221
|
/**
|
|
@@ -195,22 +243,37 @@ export declare class TTSService {
|
|
|
195
243
|
private getSegmentIndexForOffset;
|
|
196
244
|
private highlightSentenceForOffset;
|
|
197
245
|
/**
|
|
198
|
-
*
|
|
246
|
+
* Read `target` aloud: a range reads the text it selects, an element its
|
|
247
|
+
* content. A node with a spoken card that the target holds whole reads its
|
|
248
|
+
* card, `catalogId` names the card of the content root, and math reads as
|
|
249
|
+
* math speech.
|
|
199
250
|
*
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
*
|
|
251
|
+
* Content marked not-to-be-spoken is never read, a named card included. When
|
|
252
|
+
* the target holds nothing speakable, nothing is spoken and playback already
|
|
253
|
+
* running continues.
|
|
203
254
|
*/
|
|
204
|
-
|
|
255
|
+
speak(target: Range | Element, options?: SpeakOptions): Promise<void>;
|
|
205
256
|
/**
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
|
|
209
|
-
|
|
257
|
+
* Sets the rate a run starts at, after any rate write in flight. The run has
|
|
258
|
+
* no playback yet, so nothing restarts.
|
|
259
|
+
*/
|
|
260
|
+
private applyRunRate;
|
|
261
|
+
/**
|
|
262
|
+
* Suppression is read from the live ancestors of what is read, because the
|
|
263
|
+
* element carrying it may sit above the content root.
|
|
264
|
+
*/
|
|
265
|
+
private isSuppressedTarget;
|
|
266
|
+
private resolveElementTarget;
|
|
267
|
+
/** Whether the root's card, or a card of a node inside it, would be read. */
|
|
268
|
+
private holdsSpokenCard;
|
|
269
|
+
private resolveRangeTarget;
|
|
270
|
+
private speakContent;
|
|
271
|
+
/**
|
|
272
|
+
* Hand the read's language to the provider. A read in a named content language
|
|
273
|
+
* sets the provider's locales and `contentLanguage` to it, so a browser voice
|
|
274
|
+
* follows it; a read naming none restores the host's locales and clears
|
|
275
|
+
* `contentLanguage`, so the browser voice follows the browser's language.
|
|
210
276
|
*/
|
|
211
|
-
speak(text: string, options?: SpeakOptions): Promise<void>;
|
|
212
|
-
private switchProviderToBrowser;
|
|
213
|
-
private isBrowserSpeechFallbackAvailable;
|
|
214
277
|
private applyLanguageSettings;
|
|
215
278
|
private resolveSpeechContent;
|
|
216
279
|
private resolveCatalogComposedSpeechContent;
|
|
@@ -226,6 +289,10 @@ export declare class TTSService {
|
|
|
226
289
|
* defensive net if a capable provider still rejects a given SSML payload.
|
|
227
290
|
*/
|
|
228
291
|
private resolveGeneratedPlaybackFormat;
|
|
292
|
+
/**
|
|
293
|
+
* With `range`, the selection only: an equation it holds whole reads as math
|
|
294
|
+
* speech, and a selection without one reads the selected text, `normalizedInputText`.
|
|
295
|
+
*/
|
|
229
296
|
private resolveGeneratedSpeechContent;
|
|
230
297
|
private logResolvedSpeechContent;
|
|
231
298
|
private initializeSpeakTracking;
|
|
@@ -233,7 +300,6 @@ export declare class TTSService {
|
|
|
233
300
|
private configureWordBoundaryHighlighting;
|
|
234
301
|
private clearWordBoundaryHighlighting;
|
|
235
302
|
private highlightCatalogRegion;
|
|
236
|
-
private highlightCatalogActiveRange;
|
|
237
303
|
private highlightRenderableRegionTarget;
|
|
238
304
|
private highlightRenderableActiveTarget;
|
|
239
305
|
private renderHighlightDecision;
|
|
@@ -253,28 +319,19 @@ export declare class TTSService {
|
|
|
253
319
|
private speakCatalogChunkOnce;
|
|
254
320
|
private executeSpeakPlayback;
|
|
255
321
|
private clearHighlightsAndTracking;
|
|
256
|
-
/**
|
|
257
|
-
* Speak a text range with accurate word highlighting
|
|
258
|
-
*
|
|
259
|
-
* This calculates the offset of the range within its parent element
|
|
260
|
-
* to ensure word highlighting aligns correctly with the selected text.
|
|
261
|
-
*
|
|
262
|
-
* @param range DOM Range to speak
|
|
263
|
-
*/
|
|
264
322
|
/**
|
|
265
323
|
* The selected part of `root`'s normalized visible text and where it starts, or
|
|
266
324
|
* null when the map is unavailable or holds no selected character.
|
|
267
325
|
*/
|
|
268
326
|
private selectMappedRangeText;
|
|
269
|
-
speakRange(range: Range, options?: {
|
|
270
|
-
contentRoot?: Element | null;
|
|
271
|
-
}): Promise<void>;
|
|
272
327
|
/**
|
|
273
|
-
* Pause playback
|
|
328
|
+
* Pause playback. A pause while the read is loading holds it: its audio does
|
|
329
|
+
* not start until {@link resume}.
|
|
274
330
|
*/
|
|
275
331
|
pause(): void;
|
|
276
332
|
/**
|
|
277
|
-
* Resume playback
|
|
333
|
+
* Resume playback, back to loading when the pause came before the audio
|
|
334
|
+
* started.
|
|
278
335
|
*/
|
|
279
336
|
resume(): void;
|
|
280
337
|
private normalizePlaybackRate;
|
|
@@ -284,50 +341,33 @@ export declare class TTSService {
|
|
|
284
341
|
seekForward(units?: number): Promise<void>;
|
|
285
342
|
seekBackward(units?: number): Promise<void>;
|
|
286
343
|
/**
|
|
287
|
-
* Stop playback
|
|
344
|
+
* Stop playback and release the run owner. A run that ends on its own keeps
|
|
345
|
+
* its owner, so the owning control can replay it.
|
|
288
346
|
*/
|
|
289
347
|
stop(): void;
|
|
290
348
|
/**
|
|
291
|
-
*
|
|
292
|
-
*
|
|
293
|
-
* This is intentionally separate from playback controls so hosts can orchestrate
|
|
294
|
-
* control handoff explicitly (for example: stop playback, then dismiss controls).
|
|
295
|
-
*/
|
|
296
|
-
requestControlHandoff(): void;
|
|
297
|
-
/**
|
|
298
|
-
* Check if currently playing
|
|
349
|
+
* Stop playback and drop the provider, whose owner destroys it. A later speak
|
|
350
|
+
* waits on the readiness gate, as before the first {@link initialize}.
|
|
299
351
|
*/
|
|
300
|
-
|
|
352
|
+
releaseProvider(): void;
|
|
301
353
|
/**
|
|
302
|
-
*
|
|
354
|
+
* Stop, release the provider and drop every listener, hook and pending timer.
|
|
355
|
+
* A disposed service cannot speak or be initialized again.
|
|
303
356
|
*/
|
|
304
|
-
|
|
357
|
+
dispose(): void;
|
|
305
358
|
/**
|
|
306
359
|
* Get current state
|
|
307
360
|
*/
|
|
308
361
|
getState(): PlaybackState;
|
|
362
|
+
getRunOwner(): string | null;
|
|
309
363
|
/**
|
|
310
|
-
*
|
|
311
|
-
|
|
312
|
-
getCurrentText(): string | null;
|
|
313
|
-
/**
|
|
314
|
-
* Get the last error message
|
|
315
|
-
* Returns null if no error has occurred
|
|
316
|
-
*/
|
|
317
|
-
getLastError(): string | null;
|
|
318
|
-
/**
|
|
319
|
-
* Subscribe to state changes
|
|
320
|
-
*
|
|
321
|
-
* @param id Unique listener ID
|
|
322
|
-
* @param callback Function to call on state change
|
|
323
|
-
*/
|
|
324
|
-
onStateChange(id: string, callback: (state: PlaybackState) => void): void;
|
|
325
|
-
/**
|
|
326
|
-
* Unsubscribe from state changes
|
|
364
|
+
* Subscribe to playback state changes. The returned function unsubscribes;
|
|
365
|
+
* each subscription is its own, so the same callback can be subscribed twice.
|
|
327
366
|
*/
|
|
328
|
-
|
|
367
|
+
onStateChange(callback: (state: PlaybackState) => void): () => void;
|
|
329
368
|
/**
|
|
330
|
-
* Set state and notify listeners
|
|
369
|
+
* Set state and notify listeners. `announceUnchanged` notifies listeners even
|
|
370
|
+
* when the state does not change; telemetry fires only on a change.
|
|
331
371
|
*/
|
|
332
372
|
private setState;
|
|
333
373
|
}
|