ssml-builder-js 2.12.0 → 2.13.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 +26 -1
- package/dist/{chunk-4BVNAUVR.mjs → chunk-25LOR4AJ.mjs} +134 -10
- package/dist/chunk-25LOR4AJ.mjs.map +1 -0
- package/dist/chunk-CZ2F3TET.mjs +1745 -0
- package/dist/chunk-CZ2F3TET.mjs.map +1 -0
- package/dist/{chunk-FHDFRM2F.mjs → chunk-LCTE26LS.mjs} +248 -1722
- package/dist/chunk-LCTE26LS.mjs.map +1 -0
- package/dist/core.d.mts +45 -3
- package/dist/core.d.ts +45 -3
- package/dist/core.js +133 -9
- package/dist/core.js.map +1 -1
- package/dist/core.mjs +1 -1
- package/dist/elements.js +118 -1
- package/dist/elements.js.map +1 -1
- package/dist/elements.mjs +6 -4
- package/dist/elements.mjs.map +1 -1
- package/dist/index.d-Xbr6ZWnK.d.mts +214 -0
- package/dist/index.d-Xbr6ZWnK.d.ts +214 -0
- package/dist/index.d.mts +95 -2
- package/dist/index.d.ts +95 -2
- package/dist/index.js +1732 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +135 -4
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +61 -163
- package/dist/react.d.ts +61 -163
- package/dist/react.js +397 -15
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +139 -18
- package/dist/react.mjs.map +1 -1
- package/package.json +3 -2
- package/dist/chunk-4BVNAUVR.mjs.map +0 -1
- package/dist/chunk-FHDFRM2F.mjs.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { AudioElement, AzureDiagnosticCode, AzureLanguageNormalizationOptions, AzureSsmlValidationOptions, AzureValidationOptions, AzureVoiceCatalogMetadata, AzureVoiceDefinition, AzureVoiceMetadata, BookmarkElement, BreakElement, BuildPartialSsmlOptions, CustomElement, EmphasisElement, ExpressAsElement, ExtractSsmlTranslatableTextOptions, FromPlainTextToSsmlOptions, LangElement, LexiconElement, MapSsmlTextNodesOptions, MarkElement, MsttsAudioDurationElement, MsttsEmbeddingElement, MsttsSilenceElement, MsttsTtsEmbeddingElement, MsttsVisemeElement, MsttsVoiceConversionElement, NamedElement, ParagraphElement, PhonemeElement, ProsodyElement, SayAsElement, SentenceElement, SsmlAttributeValue, SsmlAttributes, SsmlBackgroundAudioNode, SsmlBreakElement, SsmlDiagnostic, SsmlDiagnosticSeverity, SsmlDiagnosticSource, SsmlDialogNode, SsmlDocument, SsmlElement, SsmlElementBase, SsmlEmbeddingNode, SsmlExpressAsElement, SsmlNode, SsmlPartialContext, SsmlPartialProsody, SsmlPartialVoice, SsmlPhonemeElement, SsmlProsodyElement, SsmlSayAsElement, SsmlStructureIntegrityResult, SsmlStructureMismatch, SsmlText, SsmlTextNodeContext, SsmlTtsEmbeddingNode, SsmlTurnNode, SsmlValidationError, SsmlVoiceConversionNode, SsmlVoiceElement, SubElement, VoiceElement, WordElement, areAzureLanguagesEquivalent, buildPartialSsml, buildSsml, extractSsmlText, extractSsmlTranslatableText, fromPlainTextToSsml, getAzureVoiceCatalogMetadata, getBuiltInVoiceCatalogMetadata, isValidAzureAudioDuration, mapSsmlTextNodes, normalizeAzureLanguage, parseSsml, splitSsmlDocument, validateAzureSsml, validateSsml, validateSsmlStructureIntegrity } from './core.js';
|
|
1
|
+
export { AudioElement, AzureDiagnosticCode, AzureLanguageNormalizationOptions, AzureSsmlValidationOptions, AzureUrlValidationResult, AzureUrlValidator, AzureValidationOptions, AzureVoiceCatalogMetadata, AzureVoiceDefinition, AzureVoiceMetadata, BookmarkElement, BreakElement, BuildPartialSsmlOptions, CustomElement, EmphasisElement, ExpressAsElement, ExtractSsmlTranslatableTextOptions, FromPlainTextToSsmlOptions, LangElement, LexiconElement, MapSsmlTextNodesOptions, MarkElement, MsttsAudioDurationElement, MsttsEmbeddingElement, MsttsSilenceElement, MsttsTtsEmbeddingElement, MsttsVisemeElement, MsttsVoiceConversionElement, NamedElement, ParagraphElement, PhonemeElement, ProsodyElement, SayAsElement, SentenceElement, SplitSsmlOptions, SsmlAttributeValue, SsmlAttributes, SsmlBackgroundAudioNode, SsmlBreakElement, SsmlChunk, SsmlChunkContext, SsmlDiagnostic, SsmlDiagnosticSeverity, SsmlDiagnosticSource, SsmlDialogNode, SsmlDocument, SsmlElement, SsmlElementBase, SsmlEmbeddingNode, SsmlExpressAsElement, SsmlNode, SsmlPartialContext, SsmlPartialProsody, SsmlPartialVoice, SsmlPhonemeElement, SsmlProsodyElement, SsmlSayAsElement, SsmlStructureIntegrityResult, SsmlStructureMismatch, SsmlText, SsmlTextNodeContext, SsmlTextRange, SsmlTtsEmbeddingNode, SsmlTurnNode, SsmlValidationError, SsmlVoiceConversionNode, SsmlVoiceElement, SubElement, VoiceElement, WordElement, areAzureLanguagesEquivalent, buildPartialSsml, buildSsml, extractSsmlText, extractSsmlTranslatableText, fromPlainTextToSsml, getAzureVoiceCatalogMetadata, getBuiltInVoiceCatalogMetadata, isValidAzureAudioDuration, mapSsmlTextNodes, normalizeAzureLanguage, parseSsml, splitSsmlDocument, validateAzureSsml, validateSsml, validateSsmlStructureIntegrity } from './core.js';
|
|
2
|
+
import { S as SsmlDiagnostic, A as AzureValidationOptions } from './index.d-Xbr6ZWnK.js';
|
|
2
3
|
|
|
3
4
|
interface TtsConfig {
|
|
4
5
|
signal?: AbortSignal;
|
|
@@ -7,19 +8,45 @@ interface TtsConfig {
|
|
|
7
8
|
subscriptionKey: string;
|
|
8
9
|
region: string;
|
|
9
10
|
outputFormat?: string;
|
|
11
|
+
/** Original plain-text range represented by this synthesis request. */
|
|
12
|
+
sourceTextRange?: {
|
|
13
|
+
start: number;
|
|
14
|
+
end: number;
|
|
15
|
+
};
|
|
16
|
+
/** Reports completion of a chunk when using synthesizeSsmlChunks. */
|
|
17
|
+
onProgress?: (event: {
|
|
18
|
+
currentChunk: number;
|
|
19
|
+
totalChunks: number;
|
|
20
|
+
percent: number;
|
|
21
|
+
}) => void;
|
|
10
22
|
}
|
|
11
23
|
interface SsmlSynthesisBoundary {
|
|
12
24
|
text: string;
|
|
13
25
|
audioOffsetMs: number;
|
|
14
26
|
durationMs: number;
|
|
27
|
+
textRange?: {
|
|
28
|
+
start: number;
|
|
29
|
+
end: number;
|
|
30
|
+
};
|
|
31
|
+
requestId?: string;
|
|
15
32
|
}
|
|
16
33
|
interface SsmlSynthesisViseme {
|
|
17
34
|
visemeId: number;
|
|
18
35
|
audioOffsetMs: number;
|
|
36
|
+
textRange?: {
|
|
37
|
+
start: number;
|
|
38
|
+
end: number;
|
|
39
|
+
};
|
|
40
|
+
requestId?: string;
|
|
19
41
|
}
|
|
20
42
|
interface SsmlSynthesisBookmark {
|
|
21
43
|
name: string;
|
|
22
44
|
audioOffsetMs: number;
|
|
45
|
+
textRange?: {
|
|
46
|
+
start: number;
|
|
47
|
+
end: number;
|
|
48
|
+
};
|
|
49
|
+
requestId?: string;
|
|
23
50
|
}
|
|
24
51
|
/** Audio and Azure Speech synchronization events emitted for one SSML request. */
|
|
25
52
|
interface SsmlSynthesisResult {
|
|
@@ -32,6 +59,28 @@ interface SsmlSynthesisResult {
|
|
|
32
59
|
wordBoundaries?: SsmlSynthesisBoundary[];
|
|
33
60
|
visemes?: SsmlSynthesisViseme[];
|
|
34
61
|
bookmarks?: SsmlSynthesisBookmark[];
|
|
62
|
+
/** Request identifier returned by Azure Speech, when available. */
|
|
63
|
+
requestId?: string;
|
|
64
|
+
/** Original plain-text range represented by the result. */
|
|
65
|
+
textRange?: {
|
|
66
|
+
start: number;
|
|
67
|
+
end: number;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
interface SsmlSynthesisChunk {
|
|
71
|
+
ssml: string;
|
|
72
|
+
originalTextRange?: {
|
|
73
|
+
start: number;
|
|
74
|
+
end: number;
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
interface SynthesizeChunksOptions {
|
|
78
|
+
onProgress?: (event: SynthesisProgressEvent) => void;
|
|
79
|
+
}
|
|
80
|
+
interface SynthesisProgressEvent {
|
|
81
|
+
currentChunk: number;
|
|
82
|
+
totalChunks: number;
|
|
83
|
+
percent: number;
|
|
35
84
|
}
|
|
36
85
|
interface AzureTtsLogger {
|
|
37
86
|
debug?: (...args: unknown[]) => void;
|
|
@@ -47,6 +96,7 @@ interface AzureTtsClientOptions {
|
|
|
47
96
|
endpoint?: string;
|
|
48
97
|
outputFormat?: string;
|
|
49
98
|
logger?: AzureTtsLogger;
|
|
99
|
+
onProgress?: (event: SynthesisProgressEvent) => void;
|
|
50
100
|
}
|
|
51
101
|
|
|
52
102
|
declare class AzureTtsError extends Error {
|
|
@@ -61,14 +111,57 @@ declare class AzureTtsSdkError extends AzureTtsError {
|
|
|
61
111
|
constructor(errorDetails: string);
|
|
62
112
|
}
|
|
63
113
|
|
|
114
|
+
interface SsmlValidationError {
|
|
115
|
+
readonly kind: "validation";
|
|
116
|
+
readonly message: string;
|
|
117
|
+
readonly diagnostics: readonly SsmlDiagnostic[];
|
|
118
|
+
}
|
|
119
|
+
type Result<T, E> = {
|
|
120
|
+
readonly ok: true;
|
|
121
|
+
readonly success: true;
|
|
122
|
+
readonly status: "success";
|
|
123
|
+
readonly value: T;
|
|
124
|
+
} | {
|
|
125
|
+
readonly ok: false;
|
|
126
|
+
readonly success: false;
|
|
127
|
+
readonly status: "validation-error" | "azure-api-error";
|
|
128
|
+
readonly error: E;
|
|
129
|
+
};
|
|
130
|
+
type SynthesisResult<T, E> = Result<T, E>;
|
|
131
|
+
type Success<T> = Extract<Result<T, never>, {
|
|
132
|
+
readonly ok: true;
|
|
133
|
+
}>;
|
|
134
|
+
type ValidationErrorResult = Extract<Result<never, SsmlValidationError>, {
|
|
135
|
+
readonly status: "validation-error";
|
|
136
|
+
}>;
|
|
137
|
+
type AzureApiErrorResult = Extract<Result<never, AzureTtsError>, {
|
|
138
|
+
readonly status: "azure-api-error";
|
|
139
|
+
}>;
|
|
140
|
+
type SsmlSynthesisSafeResult = Result<SsmlSynthesisResult, never> | Result<never, SsmlValidationError> | Result<never, AzureTtsError>;
|
|
141
|
+
interface SynthesizeSsmlSafeOptions extends AzureValidationOptions {
|
|
142
|
+
/** Optional nested form for callers that want to keep validation settings grouped. */
|
|
143
|
+
validation?: AzureValidationOptions;
|
|
144
|
+
}
|
|
145
|
+
interface SynthesisClient {
|
|
146
|
+
synthesizeSsml(ssml: string): Promise<SsmlSynthesisResult>;
|
|
147
|
+
}
|
|
148
|
+
/** Validates SSML before invoking Azure and converts validation/API failures to one result shape. */
|
|
149
|
+
declare function synthesizeSsmlSafe(client: Pick<AzureTtsClient, "synthesizeSsml"> | SynthesisClient, ssml: string, options?: SynthesizeSsmlSafeOptions): Promise<SsmlSynthesisSafeResult>;
|
|
150
|
+
|
|
64
151
|
declare class AzureTtsClient {
|
|
65
152
|
#private;
|
|
66
153
|
constructor(options: AzureTtsClientOptions);
|
|
67
154
|
synthesize(ssml: string): Promise<ArrayBuffer>;
|
|
68
155
|
synthesizeSsml(ssml: string): Promise<SsmlSynthesisResult>;
|
|
156
|
+
synthesizeChunks(chunks: readonly (SsmlSynthesisChunk | string)[], options?: SynthesizeChunksOptions): Promise<SsmlSynthesisResult>;
|
|
157
|
+
synthesizeSsmlSafe(ssml: string, options?: SynthesizeSsmlSafeOptions): Promise<SsmlSynthesisSafeResult>;
|
|
69
158
|
}
|
|
70
159
|
|
|
71
160
|
declare function synthesizeSsml(ssml: string, config: TtsConfig): Promise<SsmlSynthesisResult>;
|
|
161
|
+
/** Synthesizes chunks sequentially, annotates synchronization events, and merges the results. */
|
|
162
|
+
declare function synthesizeSsmlChunks(chunks: readonly (SsmlSynthesisChunk | string)[], config: TtsConfig): Promise<SsmlSynthesisResult>;
|
|
163
|
+
/** Concatenates audio buffers and shifts all synchronization events by prior chunk durations. */
|
|
164
|
+
declare function mergeSynthesisResults(results: readonly SsmlSynthesisResult[]): SsmlSynthesisResult;
|
|
72
165
|
/** Backward-compatible audio-only synthesis helper. */
|
|
73
166
|
declare function synthesizeSpeech(ssml: string, config: TtsConfig): Promise<ArrayBuffer>;
|
|
74
167
|
|
|
@@ -97,4 +190,4 @@ interface AzureVoiceCatalog {
|
|
|
97
190
|
/** Fetches and deduplicates the current Azure Speech voice catalog for one or more regions. */
|
|
98
191
|
declare function fetchAzureVoiceCatalog(options: FetchAzureVoiceCatalogOptions): Promise<AzureVoiceCatalog>;
|
|
99
192
|
|
|
100
|
-
export { AzureTtsClient, type AzureTtsClientOptions, AzureTtsError, type AzureTtsLogger, AzureTtsSdkError, type AzureVoiceCatalog, type AzureVoiceCatalogVoice, type FetchAzureVoiceCatalogOptions, type FetchedAzureVoiceCatalogMetadata, type SsmlSynthesisBookmark, type SsmlSynthesisBoundary, type SsmlSynthesisResult, type SsmlSynthesisViseme, type TtsConfig, fetchAzureVoiceCatalog, synthesizeSpeech, synthesizeSsml };
|
|
193
|
+
export { type AzureApiErrorResult, type SsmlValidationError as AzureSsmlValidationError, AzureTtsClient, type AzureTtsClientOptions, AzureTtsError, type AzureTtsLogger, AzureTtsSdkError, type AzureVoiceCatalog, type AzureVoiceCatalogVoice, type FetchAzureVoiceCatalogOptions, type FetchedAzureVoiceCatalogMetadata, type Result, type SsmlSynthesisBookmark, type SsmlSynthesisBoundary, type SsmlSynthesisChunk, type SsmlSynthesisResult, type SsmlSynthesisSafeResult, type SsmlSynthesisViseme, type Success, type SynthesisProgressEvent, type SynthesisResult, type SynthesizeChunksOptions, type SynthesizeSsmlSafeOptions, type TtsConfig, type ValidationErrorResult, fetchAzureVoiceCatalog, mergeSynthesisResults, synthesizeSpeech, synthesizeSsml, synthesizeSsmlChunks, synthesizeSsmlSafe };
|