@readium/speech 0.8.1 → 0.9.1
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 +10 -1
- package/build/SpeechServer/speechServerEngine.d.ts +5 -0
- package/build/WebSpeech/webSpeechEngine.d.ts +2 -0
- package/build/decorator/createLocator.d.ts +8 -4
- package/build/gnd/a11y.d.ts +2 -0
- package/build/gnd/converter.d.ts +35 -17
- package/build/gnd/dom.d.ts +1 -0
- package/build/gnd/domRangeGenerator.d.ts +9 -0
- package/build/gnd/elementHandlers.d.ts +5 -0
- package/build/gnd/idAllocator.d.ts +6 -0
- package/build/gnd/index.d.ts +3 -0
- package/build/gnd/makeGnd.d.ts +2 -1
- package/build/gnd/options.d.ts +15 -0
- package/build/gnd/prescan.d.ts +1 -0
- package/build/gnd/roles.d.ts +1 -6
- package/build/gnd/selectorGenerator.d.ts +2 -0
- package/build/gnd/textFragmentGenerator.d.ts +2 -0
- package/build/gnd/textrefFragment.d.ts +38 -0
- package/build/index.cjs +35 -35
- package/build/index.js +5108 -2052
- package/build/navigator.d.ts +1 -1
- package/build/preferences/Configurable.d.ts +1 -1
- package/build/preferences/index.d.ts +1 -1
- package/build/preferences/verbosityTables.d.ts +7 -1
- package/build/speechNavigator.d.ts +11 -2
- package/build/utils/clamp.d.ts +1 -0
- package/build/utterance.d.ts +3 -0
- package/build/utterances/contextualizations.d.ts +3 -0
- package/build/utterances/extractUtterances.d.ts +3 -3
- package/build/utterances/index.d.ts +2 -2
- package/build/utterances/roles.d.ts +8 -0
- package/build/utterances/tableStructure.d.ts +9 -0
- package/build/utterances/types.d.ts +11 -10
- package/package.json +8 -4
- package/build/utterances/announcements.d.ts +0 -2
package/build/navigator.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export interface ReadiumSpeechNavigatorContract extends Configurable<SpeechSetti
|
|
|
16
16
|
setSpeakInContentLanguage(enabled: boolean): void;
|
|
17
17
|
getSpeakInContentLanguage(): boolean;
|
|
18
18
|
loadContent(content: ReadiumSpeechUtterance | ReadiumSpeechUtterance[]): void;
|
|
19
|
-
loadGndContent(nodes: GndObject[]): void
|
|
19
|
+
loadGndContent(nodes: GndObject[]): Promise<void>;
|
|
20
20
|
getCurrentContent(): ReadiumSpeechUtterance | null;
|
|
21
21
|
getContentQueue(): ReadiumSpeechUtterance[];
|
|
22
22
|
play(): void;
|
|
@@ -7,6 +7,6 @@ export interface ConfigurablePreferences<T> {
|
|
|
7
7
|
}
|
|
8
8
|
export interface Configurable<S extends ConfigurableSettings, P extends ConfigurablePreferences<P>> {
|
|
9
9
|
settings: S;
|
|
10
|
-
submitPreferences(preferences: P): void
|
|
10
|
+
submitPreferences(preferences: P): Promise<void>;
|
|
11
11
|
preferencesEditor: IPreferencesEditor;
|
|
12
12
|
}
|
|
@@ -8,4 +8,4 @@ export { SpeechDefaults } from './SpeechDefaults.js';
|
|
|
8
8
|
export type { ISpeechDefaults } from './SpeechDefaults.js';
|
|
9
9
|
export { SpeechSettings } from './SpeechSettings.js';
|
|
10
10
|
export { SpeechPreferencesEditor } from './SpeechPreferencesEditor.js';
|
|
11
|
-
export { contextualizedAtVerbosity,
|
|
11
|
+
export { contextualizationShapesAtVerbosity, contextualizedAtVerbosity, shapeableRoles, skippedAtVerbosity, } from './verbosityTables.js';
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { GndRole } from '../gnd/types.js';
|
|
2
2
|
import { VerbosityPreset } from './SpeechPreferences.js';
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const skippedAtVerbosity: Readonly<Record<Exclude<VerbosityPreset, "custom">, ReadonlySet<GndRole>>>;
|
|
4
4
|
export declare const contextualizedAtVerbosity: Readonly<Record<Exclude<VerbosityPreset, "custom">, ReadonlySet<GndRole>>>;
|
|
5
|
+
type ContextualizationShape = "inline" | "block";
|
|
6
|
+
export declare const contextualizationShapesAtVerbosity: Readonly<Record<Exclude<VerbosityPreset, "custom">, Readonly<Partial<Record<GndRole, ContextualizationShape>>>>>;
|
|
7
|
+
export declare const shapeableRoles: readonly GndRole[];
|
|
8
|
+
export type ContextualizationShapeOverrides = Partial<Record<GndRole, Partial<Record<VerbosityPreset, ContextualizationShape>>>>;
|
|
9
|
+
export declare function resolveContextualizationShapes(verbosity: VerbosityPreset, overrides: ContextualizationShapeOverrides | undefined): Partial<Record<GndRole, ContextualizationShape>>;
|
|
10
|
+
export {};
|
|
@@ -5,11 +5,19 @@ import { ISpeechDefaults } from './preferences/SpeechDefaults';
|
|
|
5
5
|
import { ISpeechPreferences, SpeechPreferences } from './preferences/SpeechPreferences';
|
|
6
6
|
import { SpeechPreferencesEditor } from './preferences/SpeechPreferencesEditor';
|
|
7
7
|
import { SpeechSettings } from './preferences/SpeechSettings';
|
|
8
|
+
import { ContextualizationShapeOverrides } from './preferences/verbosityTables';
|
|
8
9
|
import { ReadiumSpeechUtterance } from './utterance';
|
|
10
|
+
import { Contextualizations } from './utterances/types';
|
|
9
11
|
import { ReadiumSpeechVoice } from './voices/types';
|
|
12
|
+
export interface ContextualizationOverrides {
|
|
13
|
+
contextualizations?: Contextualizations;
|
|
14
|
+
shapes?: ContextualizationShapeOverrides;
|
|
15
|
+
params?: (role: string, node: GndObject) => Record<string, string> | undefined;
|
|
16
|
+
}
|
|
10
17
|
export interface ReadiumSpeechNavigatorConfiguration {
|
|
11
18
|
preferences?: ISpeechPreferences;
|
|
12
19
|
defaults?: ISpeechDefaults;
|
|
20
|
+
contextualizationOverrides?: ContextualizationOverrides;
|
|
13
21
|
}
|
|
14
22
|
export declare class ReadiumSpeechNavigator implements ReadiumSpeechNavigatorContract {
|
|
15
23
|
private engine;
|
|
@@ -21,6 +29,7 @@ export declare class ReadiumSpeechNavigator implements ReadiumSpeechNavigatorCon
|
|
|
21
29
|
private _preferences;
|
|
22
30
|
private _settings;
|
|
23
31
|
private _preferencesEditor;
|
|
32
|
+
private readonly contextualizationOverrides?;
|
|
24
33
|
private source;
|
|
25
34
|
private contentSources;
|
|
26
35
|
private contentBlockStarts;
|
|
@@ -38,7 +47,7 @@ export declare class ReadiumSpeechNavigator implements ReadiumSpeechNavigatorCon
|
|
|
38
47
|
setSpeakInContentLanguage(enabled: boolean): void;
|
|
39
48
|
getSpeakInContentLanguage(): boolean;
|
|
40
49
|
loadContent(content: ReadiumSpeechUtterance | ReadiumSpeechUtterance[]): void;
|
|
41
|
-
loadGndContent(nodes: GndObject[]): void
|
|
50
|
+
loadGndContent(nodes: GndObject[]): Promise<void>;
|
|
42
51
|
private setContentQueue;
|
|
43
52
|
private reextract;
|
|
44
53
|
private resolveResumeIndex;
|
|
@@ -59,7 +68,7 @@ export declare class ReadiumSpeechNavigator implements ReadiumSpeechNavigatorCon
|
|
|
59
68
|
private emitContentChangeEvent;
|
|
60
69
|
get settings(): SpeechSettings;
|
|
61
70
|
get preferencesEditor(): SpeechPreferencesEditor;
|
|
62
|
-
submitPreferences(preferences: SpeechPreferences): void
|
|
71
|
+
submitPreferences(preferences: SpeechPreferences): Promise<void>;
|
|
63
72
|
private applyPreferences;
|
|
64
73
|
private sameSettingValue;
|
|
65
74
|
destroy(): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function clamp(value: number, min: number, max: number, fallback: number): number;
|
package/build/utterance.d.ts
CHANGED
|
@@ -9,13 +9,13 @@ import { ExtractUtterancesOptions } from './types.js';
|
|
|
9
9
|
* Accepts `GndObject[]` (as returned by `parseMarkup()`, or `GndDocument.guided`)
|
|
10
10
|
* rather than a wrapped document.
|
|
11
11
|
*/
|
|
12
|
-
export declare function extractUtterances(nodes: GndObject[], options: ExtractUtterancesOptions): ReadiumSpeechUtterance[]
|
|
12
|
+
export declare function extractUtterances(nodes: GndObject[], options: ExtractUtterancesOptions): Promise<ReadiumSpeechUtterance[]>;
|
|
13
13
|
/**
|
|
14
14
|
* Same as `extractUtterances()`, plus `sources[i]`: the node that produced `utterances[i]`,
|
|
15
15
|
* and `blockStarts[i]`: whether `utterances[i]` begins a new block-level element.
|
|
16
16
|
*/
|
|
17
|
-
export declare function extractUtterancesWithSources(nodes: GndObject[], options: ExtractUtterancesOptions): {
|
|
17
|
+
export declare function extractUtterancesWithSources(nodes: GndObject[], options: ExtractUtterancesOptions): Promise<{
|
|
18
18
|
utterances: ReadiumSpeechUtterance[];
|
|
19
19
|
sources: (GndObject | undefined)[];
|
|
20
20
|
blockStarts: boolean[];
|
|
21
|
-
}
|
|
21
|
+
}>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { extractUtterances } from './extractUtterances.js';
|
|
2
2
|
export { blockLevelRoles, skippableRoles } from './roles.js';
|
|
3
|
-
export {
|
|
4
|
-
export type {
|
|
3
|
+
export { defaultContextualizations } from './contextualizations.js';
|
|
4
|
+
export type { ContextualizationEntry, Contextualizations, ContextualizationOptions, ExtractUtterancesOptions } from './types.js';
|
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
import { GndRole } from '../gnd/types.js';
|
|
2
2
|
export declare const skippableRoles: GndRole[];
|
|
3
3
|
export declare const blockLevelRoles: GndRole[];
|
|
4
|
+
export declare const roleDropOverrides: Partial<Record<GndRole, {
|
|
5
|
+
drops: GndRole[];
|
|
6
|
+
unconditional?: boolean;
|
|
7
|
+
}>>;
|
|
8
|
+
export declare const deferrablePlaceholderRoles: GndRole[];
|
|
9
|
+
export declare const descriptionFoldingRoles: GndRole[];
|
|
10
|
+
export declare const valueFoldingRoles: GndRole[];
|
|
11
|
+
export declare const contentlessRoles: GndRole[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { GndObject } from '../gnd/types.js';
|
|
2
|
+
export declare function plainTextOf(node: GndObject): string;
|
|
3
|
+
export interface TableStructure {
|
|
4
|
+
lines: number;
|
|
5
|
+
columns: number;
|
|
6
|
+
rowNumbers: Map<GndObject, number>;
|
|
7
|
+
cellHeaders: Map<GndObject, string>;
|
|
8
|
+
}
|
|
9
|
+
export declare function computeTableStructure(rows: GndObject[]): TableStructure;
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { GndRole } from '../gnd/types.js';
|
|
2
|
-
export type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { GndObject, GndRole } from '../gnd/types.js';
|
|
2
|
+
export type ContextualizationEntry = string | {
|
|
3
|
+
[key: string]: ContextualizationEntry;
|
|
4
|
+
};
|
|
5
|
+
export type Contextualizations = Record<GndRole, ContextualizationEntry>;
|
|
6
|
+
export interface ContextualizationOptions {
|
|
7
|
+
contextualizations?: Contextualizations;
|
|
8
|
+
shapes?: Partial<Record<GndRole, "inline" | "block">>;
|
|
9
|
+
params?: (role: GndRole, node: GndObject) => Record<string, string> | undefined;
|
|
7
10
|
}
|
|
8
|
-
export type RoleAnnouncement = Announcement | AnnouncementPair;
|
|
9
|
-
export declare function isAnnouncementPair(a: RoleAnnouncement): a is AnnouncementPair;
|
|
10
|
-
export type Announcements = Record<AnnouncementKey, RoleAnnouncement>;
|
|
11
11
|
export interface ExtractUtterancesOptions {
|
|
12
12
|
format?: "plain" | "ssml";
|
|
13
|
-
|
|
13
|
+
contextualization?: ContextualizationOptions;
|
|
14
|
+
contextualizationLocale?: string;
|
|
14
15
|
skip?: GndRole[];
|
|
15
16
|
contextualize?: GndRole[];
|
|
16
17
|
language?: "none" | "block-level" | "always";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@readium/speech",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "A TypeScript library for implementing read aloud features with Web technologies, following best practices for digital publishing.",
|
|
5
5
|
"author": "Readium Foundation",
|
|
6
6
|
"keywords": [
|
|
@@ -50,9 +50,10 @@
|
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@ava/typescript": "^6.0.0",
|
|
53
|
+
"@types/jsdom": "^30.0.0",
|
|
53
54
|
"ava": "^6.4.0",
|
|
54
55
|
"http-server": "^14.1.1",
|
|
55
|
-
"
|
|
56
|
+
"jsdom": "^30.0.1",
|
|
56
57
|
"rimraf": "^6.0.1",
|
|
57
58
|
"ts-node": "^10.9.2",
|
|
58
59
|
"typescript": "^5.8.3",
|
|
@@ -60,8 +61,11 @@
|
|
|
60
61
|
"vite-plugin-dts": "^4.5.4"
|
|
61
62
|
},
|
|
62
63
|
"dependencies": {
|
|
63
|
-
"@readium/decorator": "
|
|
64
|
-
"@readium/
|
|
64
|
+
"@readium/decorator": "1.2.0",
|
|
65
|
+
"@readium/helpers": "1.1.0",
|
|
66
|
+
"@readium/shared": "2.5.0",
|
|
67
|
+
"css-selector-generator": "^3.9.4",
|
|
68
|
+
"i18next": "^26.4.0",
|
|
65
69
|
"string-strip-html": "^13.4.23"
|
|
66
70
|
}
|
|
67
71
|
}
|