@ssml-builder-js/azure-tts-client 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/CHANGELOG.md +11 -0
- package/dist/index.d.mts +95 -1
- package/dist/index.d.ts +95 -1
- package/dist/index.js +137 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +133 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
- package/src/client.ts +30 -2
- package/src/index.ts +15 -0
- package/src/safe.ts +72 -0
- package/src/synthesis.ts +102 -4
- package/src/types.ts +30 -0
- package/test/v213-pipeline.test.ts +68 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @ssml-builder-js/azure-tts-client
|
|
2
2
|
|
|
3
|
+
## 2.13.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Add structured SSML chunk metadata and background-audio replication policies, merged synthesis synchronization offsets, safe preflight synthesis with custom URL validation, chunk progress reporting, source tracking, and extensible Japanese-localized Visual Editor controls.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @ssml-builder-js/ssml-core@2.13.0
|
|
13
|
+
|
|
3
14
|
## 2.12.0
|
|
4
15
|
|
|
5
16
|
### Minor Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { SsmlDiagnostic, AzureValidationOptions } from '@ssml-builder-js/ssml-core';
|
|
2
|
+
|
|
1
3
|
interface TtsConfig {
|
|
2
4
|
signal?: AbortSignal;
|
|
3
5
|
timeoutMs?: number;
|
|
@@ -5,19 +7,45 @@ interface TtsConfig {
|
|
|
5
7
|
subscriptionKey: string;
|
|
6
8
|
region: string;
|
|
7
9
|
outputFormat?: string;
|
|
10
|
+
/** Original plain-text range represented by this synthesis request. */
|
|
11
|
+
sourceTextRange?: {
|
|
12
|
+
start: number;
|
|
13
|
+
end: number;
|
|
14
|
+
};
|
|
15
|
+
/** Reports completion of a chunk when using synthesizeSsmlChunks. */
|
|
16
|
+
onProgress?: (event: {
|
|
17
|
+
currentChunk: number;
|
|
18
|
+
totalChunks: number;
|
|
19
|
+
percent: number;
|
|
20
|
+
}) => void;
|
|
8
21
|
}
|
|
9
22
|
interface SsmlSynthesisBoundary {
|
|
10
23
|
text: string;
|
|
11
24
|
audioOffsetMs: number;
|
|
12
25
|
durationMs: number;
|
|
26
|
+
textRange?: {
|
|
27
|
+
start: number;
|
|
28
|
+
end: number;
|
|
29
|
+
};
|
|
30
|
+
requestId?: string;
|
|
13
31
|
}
|
|
14
32
|
interface SsmlSynthesisViseme {
|
|
15
33
|
visemeId: number;
|
|
16
34
|
audioOffsetMs: number;
|
|
35
|
+
textRange?: {
|
|
36
|
+
start: number;
|
|
37
|
+
end: number;
|
|
38
|
+
};
|
|
39
|
+
requestId?: string;
|
|
17
40
|
}
|
|
18
41
|
interface SsmlSynthesisBookmark {
|
|
19
42
|
name: string;
|
|
20
43
|
audioOffsetMs: number;
|
|
44
|
+
textRange?: {
|
|
45
|
+
start: number;
|
|
46
|
+
end: number;
|
|
47
|
+
};
|
|
48
|
+
requestId?: string;
|
|
21
49
|
}
|
|
22
50
|
/** Audio and Azure Speech synchronization events emitted for one SSML request. */
|
|
23
51
|
interface SsmlSynthesisResult {
|
|
@@ -30,6 +58,28 @@ interface SsmlSynthesisResult {
|
|
|
30
58
|
wordBoundaries?: SsmlSynthesisBoundary[];
|
|
31
59
|
visemes?: SsmlSynthesisViseme[];
|
|
32
60
|
bookmarks?: SsmlSynthesisBookmark[];
|
|
61
|
+
/** Request identifier returned by Azure Speech, when available. */
|
|
62
|
+
requestId?: string;
|
|
63
|
+
/** Original plain-text range represented by the result. */
|
|
64
|
+
textRange?: {
|
|
65
|
+
start: number;
|
|
66
|
+
end: number;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
interface SsmlSynthesisChunk {
|
|
70
|
+
ssml: string;
|
|
71
|
+
originalTextRange?: {
|
|
72
|
+
start: number;
|
|
73
|
+
end: number;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
interface SynthesizeChunksOptions {
|
|
77
|
+
onProgress?: (event: SynthesisProgressEvent) => void;
|
|
78
|
+
}
|
|
79
|
+
interface SynthesisProgressEvent {
|
|
80
|
+
currentChunk: number;
|
|
81
|
+
totalChunks: number;
|
|
82
|
+
percent: number;
|
|
33
83
|
}
|
|
34
84
|
interface AzureTtsLogger {
|
|
35
85
|
debug?: (...args: unknown[]) => void;
|
|
@@ -45,6 +95,7 @@ interface AzureTtsClientOptions {
|
|
|
45
95
|
endpoint?: string;
|
|
46
96
|
outputFormat?: string;
|
|
47
97
|
logger?: AzureTtsLogger;
|
|
98
|
+
onProgress?: (event: SynthesisProgressEvent) => void;
|
|
48
99
|
}
|
|
49
100
|
|
|
50
101
|
declare class AzureTtsError extends Error {
|
|
@@ -59,14 +110,57 @@ declare class AzureTtsSdkError extends AzureTtsError {
|
|
|
59
110
|
constructor(errorDetails: string);
|
|
60
111
|
}
|
|
61
112
|
|
|
113
|
+
interface SsmlValidationError {
|
|
114
|
+
readonly kind: "validation";
|
|
115
|
+
readonly message: string;
|
|
116
|
+
readonly diagnostics: readonly SsmlDiagnostic[];
|
|
117
|
+
}
|
|
118
|
+
type Result<T, E> = {
|
|
119
|
+
readonly ok: true;
|
|
120
|
+
readonly success: true;
|
|
121
|
+
readonly status: "success";
|
|
122
|
+
readonly value: T;
|
|
123
|
+
} | {
|
|
124
|
+
readonly ok: false;
|
|
125
|
+
readonly success: false;
|
|
126
|
+
readonly status: "validation-error" | "azure-api-error";
|
|
127
|
+
readonly error: E;
|
|
128
|
+
};
|
|
129
|
+
type SynthesisResult<T, E> = Result<T, E>;
|
|
130
|
+
type Success<T> = Extract<Result<T, never>, {
|
|
131
|
+
readonly ok: true;
|
|
132
|
+
}>;
|
|
133
|
+
type ValidationErrorResult = Extract<Result<never, SsmlValidationError>, {
|
|
134
|
+
readonly status: "validation-error";
|
|
135
|
+
}>;
|
|
136
|
+
type AzureApiErrorResult = Extract<Result<never, AzureTtsError>, {
|
|
137
|
+
readonly status: "azure-api-error";
|
|
138
|
+
}>;
|
|
139
|
+
type SsmlSynthesisSafeResult = Result<SsmlSynthesisResult, never> | Result<never, SsmlValidationError> | Result<never, AzureTtsError>;
|
|
140
|
+
interface SynthesizeSsmlSafeOptions extends AzureValidationOptions {
|
|
141
|
+
/** Optional nested form for callers that want to keep validation settings grouped. */
|
|
142
|
+
validation?: AzureValidationOptions;
|
|
143
|
+
}
|
|
144
|
+
interface SynthesisClient {
|
|
145
|
+
synthesizeSsml(ssml: string): Promise<SsmlSynthesisResult>;
|
|
146
|
+
}
|
|
147
|
+
/** Validates SSML before invoking Azure and converts validation/API failures to one result shape. */
|
|
148
|
+
declare function synthesizeSsmlSafe(client: Pick<AzureTtsClient, "synthesizeSsml"> | SynthesisClient, ssml: string, options?: SynthesizeSsmlSafeOptions): Promise<SsmlSynthesisSafeResult>;
|
|
149
|
+
|
|
62
150
|
declare class AzureTtsClient {
|
|
63
151
|
#private;
|
|
64
152
|
constructor(options: AzureTtsClientOptions);
|
|
65
153
|
synthesize(ssml: string): Promise<ArrayBuffer>;
|
|
66
154
|
synthesizeSsml(ssml: string): Promise<SsmlSynthesisResult>;
|
|
155
|
+
synthesizeChunks(chunks: readonly (SsmlSynthesisChunk | string)[], options?: SynthesizeChunksOptions): Promise<SsmlSynthesisResult>;
|
|
156
|
+
synthesizeSsmlSafe(ssml: string, options?: SynthesizeSsmlSafeOptions): Promise<SsmlSynthesisSafeResult>;
|
|
67
157
|
}
|
|
68
158
|
|
|
69
159
|
declare function synthesizeSsml(ssml: string, config: TtsConfig): Promise<SsmlSynthesisResult>;
|
|
160
|
+
/** Synthesizes chunks sequentially, annotates synchronization events, and merges the results. */
|
|
161
|
+
declare function synthesizeSsmlChunks(chunks: readonly (SsmlSynthesisChunk | string)[], config: TtsConfig): Promise<SsmlSynthesisResult>;
|
|
162
|
+
/** Concatenates audio buffers and shifts all synchronization events by prior chunk durations. */
|
|
163
|
+
declare function mergeSynthesisResults(results: readonly SsmlSynthesisResult[]): SsmlSynthesisResult;
|
|
70
164
|
/** Backward-compatible audio-only synthesis helper. */
|
|
71
165
|
declare function synthesizeSpeech(ssml: string, config: TtsConfig): Promise<ArrayBuffer>;
|
|
72
166
|
|
|
@@ -95,4 +189,4 @@ interface AzureVoiceCatalog {
|
|
|
95
189
|
/** Fetches and deduplicates the current Azure Speech voice catalog for one or more regions. */
|
|
96
190
|
declare function fetchAzureVoiceCatalog(options: FetchAzureVoiceCatalogOptions): Promise<AzureVoiceCatalog>;
|
|
97
191
|
|
|
98
|
-
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 };
|
|
192
|
+
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { SsmlDiagnostic, AzureValidationOptions } from '@ssml-builder-js/ssml-core';
|
|
2
|
+
|
|
1
3
|
interface TtsConfig {
|
|
2
4
|
signal?: AbortSignal;
|
|
3
5
|
timeoutMs?: number;
|
|
@@ -5,19 +7,45 @@ interface TtsConfig {
|
|
|
5
7
|
subscriptionKey: string;
|
|
6
8
|
region: string;
|
|
7
9
|
outputFormat?: string;
|
|
10
|
+
/** Original plain-text range represented by this synthesis request. */
|
|
11
|
+
sourceTextRange?: {
|
|
12
|
+
start: number;
|
|
13
|
+
end: number;
|
|
14
|
+
};
|
|
15
|
+
/** Reports completion of a chunk when using synthesizeSsmlChunks. */
|
|
16
|
+
onProgress?: (event: {
|
|
17
|
+
currentChunk: number;
|
|
18
|
+
totalChunks: number;
|
|
19
|
+
percent: number;
|
|
20
|
+
}) => void;
|
|
8
21
|
}
|
|
9
22
|
interface SsmlSynthesisBoundary {
|
|
10
23
|
text: string;
|
|
11
24
|
audioOffsetMs: number;
|
|
12
25
|
durationMs: number;
|
|
26
|
+
textRange?: {
|
|
27
|
+
start: number;
|
|
28
|
+
end: number;
|
|
29
|
+
};
|
|
30
|
+
requestId?: string;
|
|
13
31
|
}
|
|
14
32
|
interface SsmlSynthesisViseme {
|
|
15
33
|
visemeId: number;
|
|
16
34
|
audioOffsetMs: number;
|
|
35
|
+
textRange?: {
|
|
36
|
+
start: number;
|
|
37
|
+
end: number;
|
|
38
|
+
};
|
|
39
|
+
requestId?: string;
|
|
17
40
|
}
|
|
18
41
|
interface SsmlSynthesisBookmark {
|
|
19
42
|
name: string;
|
|
20
43
|
audioOffsetMs: number;
|
|
44
|
+
textRange?: {
|
|
45
|
+
start: number;
|
|
46
|
+
end: number;
|
|
47
|
+
};
|
|
48
|
+
requestId?: string;
|
|
21
49
|
}
|
|
22
50
|
/** Audio and Azure Speech synchronization events emitted for one SSML request. */
|
|
23
51
|
interface SsmlSynthesisResult {
|
|
@@ -30,6 +58,28 @@ interface SsmlSynthesisResult {
|
|
|
30
58
|
wordBoundaries?: SsmlSynthesisBoundary[];
|
|
31
59
|
visemes?: SsmlSynthesisViseme[];
|
|
32
60
|
bookmarks?: SsmlSynthesisBookmark[];
|
|
61
|
+
/** Request identifier returned by Azure Speech, when available. */
|
|
62
|
+
requestId?: string;
|
|
63
|
+
/** Original plain-text range represented by the result. */
|
|
64
|
+
textRange?: {
|
|
65
|
+
start: number;
|
|
66
|
+
end: number;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
interface SsmlSynthesisChunk {
|
|
70
|
+
ssml: string;
|
|
71
|
+
originalTextRange?: {
|
|
72
|
+
start: number;
|
|
73
|
+
end: number;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
interface SynthesizeChunksOptions {
|
|
77
|
+
onProgress?: (event: SynthesisProgressEvent) => void;
|
|
78
|
+
}
|
|
79
|
+
interface SynthesisProgressEvent {
|
|
80
|
+
currentChunk: number;
|
|
81
|
+
totalChunks: number;
|
|
82
|
+
percent: number;
|
|
33
83
|
}
|
|
34
84
|
interface AzureTtsLogger {
|
|
35
85
|
debug?: (...args: unknown[]) => void;
|
|
@@ -45,6 +95,7 @@ interface AzureTtsClientOptions {
|
|
|
45
95
|
endpoint?: string;
|
|
46
96
|
outputFormat?: string;
|
|
47
97
|
logger?: AzureTtsLogger;
|
|
98
|
+
onProgress?: (event: SynthesisProgressEvent) => void;
|
|
48
99
|
}
|
|
49
100
|
|
|
50
101
|
declare class AzureTtsError extends Error {
|
|
@@ -59,14 +110,57 @@ declare class AzureTtsSdkError extends AzureTtsError {
|
|
|
59
110
|
constructor(errorDetails: string);
|
|
60
111
|
}
|
|
61
112
|
|
|
113
|
+
interface SsmlValidationError {
|
|
114
|
+
readonly kind: "validation";
|
|
115
|
+
readonly message: string;
|
|
116
|
+
readonly diagnostics: readonly SsmlDiagnostic[];
|
|
117
|
+
}
|
|
118
|
+
type Result<T, E> = {
|
|
119
|
+
readonly ok: true;
|
|
120
|
+
readonly success: true;
|
|
121
|
+
readonly status: "success";
|
|
122
|
+
readonly value: T;
|
|
123
|
+
} | {
|
|
124
|
+
readonly ok: false;
|
|
125
|
+
readonly success: false;
|
|
126
|
+
readonly status: "validation-error" | "azure-api-error";
|
|
127
|
+
readonly error: E;
|
|
128
|
+
};
|
|
129
|
+
type SynthesisResult<T, E> = Result<T, E>;
|
|
130
|
+
type Success<T> = Extract<Result<T, never>, {
|
|
131
|
+
readonly ok: true;
|
|
132
|
+
}>;
|
|
133
|
+
type ValidationErrorResult = Extract<Result<never, SsmlValidationError>, {
|
|
134
|
+
readonly status: "validation-error";
|
|
135
|
+
}>;
|
|
136
|
+
type AzureApiErrorResult = Extract<Result<never, AzureTtsError>, {
|
|
137
|
+
readonly status: "azure-api-error";
|
|
138
|
+
}>;
|
|
139
|
+
type SsmlSynthesisSafeResult = Result<SsmlSynthesisResult, never> | Result<never, SsmlValidationError> | Result<never, AzureTtsError>;
|
|
140
|
+
interface SynthesizeSsmlSafeOptions extends AzureValidationOptions {
|
|
141
|
+
/** Optional nested form for callers that want to keep validation settings grouped. */
|
|
142
|
+
validation?: AzureValidationOptions;
|
|
143
|
+
}
|
|
144
|
+
interface SynthesisClient {
|
|
145
|
+
synthesizeSsml(ssml: string): Promise<SsmlSynthesisResult>;
|
|
146
|
+
}
|
|
147
|
+
/** Validates SSML before invoking Azure and converts validation/API failures to one result shape. */
|
|
148
|
+
declare function synthesizeSsmlSafe(client: Pick<AzureTtsClient, "synthesizeSsml"> | SynthesisClient, ssml: string, options?: SynthesizeSsmlSafeOptions): Promise<SsmlSynthesisSafeResult>;
|
|
149
|
+
|
|
62
150
|
declare class AzureTtsClient {
|
|
63
151
|
#private;
|
|
64
152
|
constructor(options: AzureTtsClientOptions);
|
|
65
153
|
synthesize(ssml: string): Promise<ArrayBuffer>;
|
|
66
154
|
synthesizeSsml(ssml: string): Promise<SsmlSynthesisResult>;
|
|
155
|
+
synthesizeChunks(chunks: readonly (SsmlSynthesisChunk | string)[], options?: SynthesizeChunksOptions): Promise<SsmlSynthesisResult>;
|
|
156
|
+
synthesizeSsmlSafe(ssml: string, options?: SynthesizeSsmlSafeOptions): Promise<SsmlSynthesisSafeResult>;
|
|
67
157
|
}
|
|
68
158
|
|
|
69
159
|
declare function synthesizeSsml(ssml: string, config: TtsConfig): Promise<SsmlSynthesisResult>;
|
|
160
|
+
/** Synthesizes chunks sequentially, annotates synchronization events, and merges the results. */
|
|
161
|
+
declare function synthesizeSsmlChunks(chunks: readonly (SsmlSynthesisChunk | string)[], config: TtsConfig): Promise<SsmlSynthesisResult>;
|
|
162
|
+
/** Concatenates audio buffers and shifts all synchronization events by prior chunk durations. */
|
|
163
|
+
declare function mergeSynthesisResults(results: readonly SsmlSynthesisResult[]): SsmlSynthesisResult;
|
|
70
164
|
/** Backward-compatible audio-only synthesis helper. */
|
|
71
165
|
declare function synthesizeSpeech(ssml: string, config: TtsConfig): Promise<ArrayBuffer>;
|
|
72
166
|
|
|
@@ -95,4 +189,4 @@ interface AzureVoiceCatalog {
|
|
|
95
189
|
/** Fetches and deduplicates the current Azure Speech voice catalog for one or more regions. */
|
|
96
190
|
declare function fetchAzureVoiceCatalog(options: FetchAzureVoiceCatalogOptions): Promise<AzureVoiceCatalog>;
|
|
97
191
|
|
|
98
|
-
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 };
|
|
192
|
+
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 };
|
package/dist/index.js
CHANGED
|
@@ -41,8 +41,11 @@ __export(index_exports, {
|
|
|
41
41
|
AzureTtsError: () => AzureTtsError,
|
|
42
42
|
AzureTtsSdkError: () => AzureTtsSdkError,
|
|
43
43
|
fetchAzureVoiceCatalog: () => fetchAzureVoiceCatalog,
|
|
44
|
+
mergeSynthesisResults: () => mergeSynthesisResults,
|
|
44
45
|
synthesizeSpeech: () => synthesizeSpeech,
|
|
45
|
-
synthesizeSsml: () => synthesizeSsml
|
|
46
|
+
synthesizeSsml: () => synthesizeSsml,
|
|
47
|
+
synthesizeSsmlChunks: () => synthesizeSsmlChunks,
|
|
48
|
+
synthesizeSsmlSafe: () => synthesizeSsmlSafe
|
|
46
49
|
});
|
|
47
50
|
module.exports = __toCommonJS(index_exports);
|
|
48
51
|
|
|
@@ -214,12 +217,23 @@ async function synthesizeSsml(ssml, config) {
|
|
|
214
217
|
...(bookmarks ?? []).map((bookmark) => bookmark.audioOffsetMs)
|
|
215
218
|
);
|
|
216
219
|
const durationMs = result.audioDuration ? ticksToMilliseconds(result.audioDuration) : eventDurationMs;
|
|
220
|
+
const requestId = result.resultId;
|
|
221
|
+
const addSourceMetadata = (event) => ({
|
|
222
|
+
...event,
|
|
223
|
+
...config.sourceTextRange ? { textRange: { ...config.sourceTextRange } } : {},
|
|
224
|
+
...requestId ? { requestId } : {}
|
|
225
|
+
});
|
|
226
|
+
const sourceBoundaries = boundaries.map((boundary) => addSourceMetadata(boundary));
|
|
227
|
+
const sourceVisemes = visemes.map((viseme) => addSourceMetadata(viseme));
|
|
228
|
+
const sourceBookmarks = bookmarks.map((bookmark) => addSourceMetadata(bookmark));
|
|
217
229
|
resolve({
|
|
218
230
|
audioData: result.audioData,
|
|
219
231
|
durationMs,
|
|
220
|
-
...
|
|
221
|
-
...
|
|
222
|
-
...
|
|
232
|
+
...config.sourceTextRange ? { textRange: { ...config.sourceTextRange } } : {},
|
|
233
|
+
...requestId ? { requestId } : {},
|
|
234
|
+
...sourceBoundaries.length > 0 ? { boundaries: sourceBoundaries, wordBoundary: sourceBoundaries, wordBoundaries: sourceBoundaries } : {},
|
|
235
|
+
...sourceVisemes.length > 0 ? { visemes: sourceVisemes } : {},
|
|
236
|
+
...sourceBookmarks.length > 0 ? { bookmarks: sourceBookmarks } : {}
|
|
223
237
|
});
|
|
224
238
|
};
|
|
225
239
|
try {
|
|
@@ -239,10 +253,109 @@ async function synthesizeSsml(ssml, config) {
|
|
|
239
253
|
}
|
|
240
254
|
});
|
|
241
255
|
}
|
|
256
|
+
async function synthesizeSsmlChunks(chunks, config) {
|
|
257
|
+
const results = [];
|
|
258
|
+
const totalChunks = chunks.length;
|
|
259
|
+
for (const [index, chunk] of chunks.entries()) {
|
|
260
|
+
const input = typeof chunk === "string" ? { ssml: chunk } : chunk;
|
|
261
|
+
const result = await synthesizeSsml(input.ssml, {
|
|
262
|
+
...config,
|
|
263
|
+
...input.originalTextRange ? { sourceTextRange: input.originalTextRange } : {},
|
|
264
|
+
onProgress: void 0
|
|
265
|
+
});
|
|
266
|
+
results.push(result);
|
|
267
|
+
config.onProgress?.({
|
|
268
|
+
currentChunk: index + 1,
|
|
269
|
+
totalChunks,
|
|
270
|
+
percent: totalChunks === 0 ? 100 : Math.round((index + 1) / totalChunks * 100)
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
return mergeSynthesisResults(results);
|
|
274
|
+
}
|
|
275
|
+
function mergeSynthesisResults(results) {
|
|
276
|
+
const audioLength = results.reduce((total, result) => total + result.audioData.byteLength, 0);
|
|
277
|
+
const audioData = new Uint8Array(audioLength);
|
|
278
|
+
const boundaries = [];
|
|
279
|
+
const visemes = [];
|
|
280
|
+
const bookmarks = [];
|
|
281
|
+
let byteOffset = 0;
|
|
282
|
+
let durationOffset = 0;
|
|
283
|
+
for (const result of results) {
|
|
284
|
+
audioData.set(new Uint8Array(result.audioData), byteOffset);
|
|
285
|
+
byteOffset += result.audioData.byteLength;
|
|
286
|
+
const chunkBoundaries = result.boundaries && result.boundaries.length > 0 ? result.boundaries : result.wordBoundary ?? result.wordBoundaries ?? [];
|
|
287
|
+
for (const boundary of chunkBoundaries) {
|
|
288
|
+
const textRange = boundary.textRange ?? result.textRange;
|
|
289
|
+
const requestId = boundary.requestId ?? result.requestId;
|
|
290
|
+
boundaries.push({
|
|
291
|
+
...boundary,
|
|
292
|
+
audioOffsetMs: boundary.audioOffsetMs + durationOffset,
|
|
293
|
+
...textRange ? { textRange: { ...textRange } } : {},
|
|
294
|
+
...requestId ? { requestId } : {}
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
for (const viseme of result.visemes ?? []) {
|
|
298
|
+
const textRange = viseme.textRange ?? result.textRange;
|
|
299
|
+
const requestId = viseme.requestId ?? result.requestId;
|
|
300
|
+
visemes.push({
|
|
301
|
+
...viseme,
|
|
302
|
+
audioOffsetMs: viseme.audioOffsetMs + durationOffset,
|
|
303
|
+
...textRange ? { textRange: { ...textRange } } : {},
|
|
304
|
+
...requestId ? { requestId } : {}
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
for (const bookmark of result.bookmarks ?? []) {
|
|
308
|
+
const textRange = bookmark.textRange ?? result.textRange;
|
|
309
|
+
const requestId = bookmark.requestId ?? result.requestId;
|
|
310
|
+
bookmarks.push({
|
|
311
|
+
...bookmark,
|
|
312
|
+
audioOffsetMs: bookmark.audioOffsetMs + durationOffset,
|
|
313
|
+
...textRange ? { textRange: { ...textRange } } : {},
|
|
314
|
+
...requestId ? { requestId } : {}
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
durationOffset += Math.max(0, result.durationMs);
|
|
318
|
+
}
|
|
319
|
+
return {
|
|
320
|
+
audioData: audioData.buffer,
|
|
321
|
+
durationMs: durationOffset,
|
|
322
|
+
...boundaries.length > 0 ? { boundaries, wordBoundary: boundaries, wordBoundaries: boundaries } : {},
|
|
323
|
+
...visemes.length > 0 ? { visemes } : {},
|
|
324
|
+
...bookmarks.length > 0 ? { bookmarks } : {},
|
|
325
|
+
...results.length === 1 && results[0]?.requestId ? { requestId: results[0].requestId } : {},
|
|
326
|
+
...results.length === 1 && results[0]?.textRange ? { textRange: { ...results[0].textRange } } : {}
|
|
327
|
+
};
|
|
328
|
+
}
|
|
242
329
|
async function synthesizeSpeech(ssml, config) {
|
|
243
330
|
return (await synthesizeSsml(ssml, config)).audioData;
|
|
244
331
|
}
|
|
245
332
|
|
|
333
|
+
// src/safe.ts
|
|
334
|
+
var import_ssml_core = require("@ssml-builder-js/ssml-core");
|
|
335
|
+
async function synthesizeSsmlSafe(client, ssml, options = {}) {
|
|
336
|
+
const validationOptions = options.validation ?? options;
|
|
337
|
+
const diagnostics = await Promise.resolve((0, import_ssml_core.validateAzureSsml)(ssml, validationOptions));
|
|
338
|
+
const errors = diagnostics.filter((diagnostic) => diagnostic.severity === "error");
|
|
339
|
+
if (errors.length > 0) {
|
|
340
|
+
return {
|
|
341
|
+
ok: false,
|
|
342
|
+
success: false,
|
|
343
|
+
status: "validation-error",
|
|
344
|
+
error: {
|
|
345
|
+
kind: "validation",
|
|
346
|
+
message: "SSML validation failed; the Azure Speech API was not called.",
|
|
347
|
+
diagnostics: errors
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
try {
|
|
352
|
+
return { ok: true, success: true, status: "success", value: await client.synthesizeSsml(ssml) };
|
|
353
|
+
} catch (error) {
|
|
354
|
+
const azureError = error instanceof AzureTtsError ? error : createSpeechSdkError(error);
|
|
355
|
+
return { ok: false, success: false, status: "azure-api-error", error: azureError };
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
246
359
|
// src/client.ts
|
|
247
360
|
var ENDPOINT_TEMPLATE = "https://{region}.tts.speech.microsoft.com/cognitiveservices/v1";
|
|
248
361
|
var _options;
|
|
@@ -264,6 +377,22 @@ var AzureTtsClient = class {
|
|
|
264
377
|
__privateGet(this, _options).logger?.debug?.("Using Azure TTS endpoint:", endpoint);
|
|
265
378
|
return synthesizeSsml(ssml, { endpoint, region, subscriptionKey, outputFormat, signal, timeoutMs });
|
|
266
379
|
}
|
|
380
|
+
async synthesizeChunks(chunks, options = {}) {
|
|
381
|
+
const { region, subscriptionKey, outputFormat, signal, timeoutMs } = __privateGet(this, _options);
|
|
382
|
+
const endpoint = __privateGet(this, _options).endpoint?.trim() || ENDPOINT_TEMPLATE.replace("{region}", region);
|
|
383
|
+
return synthesizeSsmlChunks(chunks, {
|
|
384
|
+
endpoint,
|
|
385
|
+
region,
|
|
386
|
+
subscriptionKey,
|
|
387
|
+
outputFormat,
|
|
388
|
+
signal,
|
|
389
|
+
timeoutMs,
|
|
390
|
+
onProgress: options.onProgress ?? __privateGet(this, _options).onProgress
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
async synthesizeSsmlSafe(ssml, options = {}) {
|
|
394
|
+
return synthesizeSsmlSafe(this, ssml, options);
|
|
395
|
+
}
|
|
267
396
|
};
|
|
268
397
|
_options = new WeakMap();
|
|
269
398
|
|
|
@@ -350,7 +479,10 @@ async function fetchAzureVoiceCatalog(options) {
|
|
|
350
479
|
AzureTtsError,
|
|
351
480
|
AzureTtsSdkError,
|
|
352
481
|
fetchAzureVoiceCatalog,
|
|
482
|
+
mergeSynthesisResults,
|
|
353
483
|
synthesizeSpeech,
|
|
354
|
-
synthesizeSsml
|
|
484
|
+
synthesizeSsml,
|
|
485
|
+
synthesizeSsmlChunks,
|
|
486
|
+
synthesizeSsmlSafe
|
|
355
487
|
});
|
|
356
488
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/errors.ts","../src/synthesis.ts","../src/speechConfig.ts","../src/outputFormats.ts","../src/client.ts","../src/voiceCatalog.ts"],"sourcesContent":["/**\n * azure-tts-client: Azure Text-to-Speech client for SSML playback.\n */\n\nexport type {\n AzureTtsClientOptions,\n AzureTtsLogger,\n SsmlSynthesisBookmark,\n SsmlSynthesisBoundary,\n SsmlSynthesisResult,\n SsmlSynthesisViseme,\n TtsConfig,\n} from \"./types.ts\";\nexport { AzureTtsError, AzureTtsSdkError } from \"./errors.ts\";\nexport { AzureTtsClient } from \"./client.ts\";\nexport { synthesizeSpeech } from \"./synthesis.ts\";\nexport { synthesizeSsml } from \"./synthesis.ts\";\nexport { fetchAzureVoiceCatalog } from \"./voiceCatalog.ts\";\nexport type {\n AzureVoiceCatalog,\n AzureVoiceCatalogVoice,\n FetchedAzureVoiceCatalogMetadata,\n FetchAzureVoiceCatalogOptions,\n} from \"./voiceCatalog.ts\";\n","export class AzureTtsError extends Error {\n readonly status: number;\n readonly statusText: string;\n readonly responseBody: string;\n readonly requestId: string | null;\n\n constructor(status: number, statusText: string, responseBody: string, requestId: string | null) {\n super(`Azure TTS request failed: ${status} ${statusText}`);\n this.name = \"AzureTtsError\";\n this.status = status;\n this.statusText = statusText;\n this.responseBody = responseBody;\n this.requestId = requestId;\n }\n}\n\nexport class AzureTtsSdkError extends AzureTtsError {\n readonly errorDetails: string;\n\n constructor(errorDetails: string) {\n super(0, \"Speech SDK\", errorDetails, null);\n this.name = \"AzureTtsSdkError\";\n this.message = `Azure TTS synthesis failed: ${errorDetails}`;\n this.errorDetails = errorDetails;\n }\n}\n\nexport function createSpeechSdkError(error: unknown): AzureTtsSdkError {\n const message = error instanceof Error ? error.message : String(error);\n return new AzureTtsSdkError(message);\n}\n","import * as SpeechSDK from \"microsoft-cognitiveservices-speech-sdk\";\nimport { createSpeechSdkError } from \"./errors.ts\";\nimport { createSpeechConfig } from \"./speechConfig.ts\";\nimport type { SsmlSynthesisResult, TtsConfig } from \"./types.ts\";\n\nfunction closeSpeechResources(speechConfig: SpeechSDK.SpeechConfig, synthesizer: SpeechSDK.SpeechSynthesizer): void {\n try {\n synthesizer.close();\n } catch {}\n\n try {\n speechConfig.close();\n } catch {}\n}\n\nconst ticksToMilliseconds = (ticks: number): number => Math.max(0, ticks) / 10_000;\n\nexport async function synthesizeSsml(ssml: string, config: TtsConfig): Promise<SsmlSynthesisResult> {\n if (config.signal?.aborted) {\n throw createSpeechSdkError(\"Speech synthesis was cancelled.\");\n }\n\n const speechConfig = createSpeechConfig(config);\n const synthesizer = new SpeechSDK.SpeechSynthesizer(speechConfig, null);\n\n return await new Promise<SsmlSynthesisResult>((resolve, reject) => {\n let resourcesClosed = false;\n let settled = false;\n let timeout: ReturnType<typeof setTimeout> | undefined;\n let abortHandler: (() => void) | undefined;\n const cleanup = () => {\n if (timeout) clearTimeout(timeout);\n if (abortHandler) config.signal?.removeEventListener(\"abort\", abortHandler);\n };\n const closeResources = () => {\n if (resourcesClosed) return;\n resourcesClosed = true;\n closeSpeechResources(speechConfig, synthesizer);\n };\n const rejectWithError = (error: unknown) => {\n if (settled) return;\n settled = true;\n cleanup();\n closeResources();\n reject(createSpeechSdkError(error));\n };\n\n const boundaries: SsmlSynthesisResult[\"boundaries\"] = [];\n const visemes: SsmlSynthesisResult[\"visemes\"] = [];\n const bookmarks: SsmlSynthesisResult[\"bookmarks\"] = [];\n synthesizer.wordBoundary = (_sender, event) => {\n boundaries.push({\n text: event.text,\n audioOffsetMs: ticksToMilliseconds(event.audioOffset),\n durationMs: ticksToMilliseconds(event.duration),\n });\n };\n synthesizer.visemeReceived = (_sender, event) => {\n visemes.push({ visemeId: event.visemeId, audioOffsetMs: ticksToMilliseconds(event.audioOffset) });\n };\n synthesizer.bookmarkReached = (_sender, event) => {\n bookmarks.push({ name: event.text, audioOffsetMs: ticksToMilliseconds(event.audioOffset) });\n };\n\n const cb = (result: SpeechSDK.SpeechSynthesisResult) => {\n if (settled) return;\n const { reason, errorDetails } = result;\n if (reason !== SpeechSDK.ResultReason.SynthesizingAudioCompleted) {\n const err = errorDetails || `Speech synthesis failed with reason ${reason}.`;\n rejectWithError(err);\n return;\n }\n settled = true;\n cleanup();\n closeResources();\n const eventDurationMs = Math.max(\n 0,\n ...(boundaries ?? []).map((boundary) => boundary.audioOffsetMs + boundary.durationMs),\n ...(visemes ?? []).map((viseme) => viseme.audioOffsetMs),\n ...(bookmarks ?? []).map((bookmark) => bookmark.audioOffsetMs),\n );\n const durationMs = result.audioDuration ? ticksToMilliseconds(result.audioDuration) : eventDurationMs;\n resolve({\n audioData: result.audioData,\n durationMs,\n ...(boundaries.length > 0 ? { boundaries, wordBoundary: boundaries, wordBoundaries: boundaries } : {}),\n ...(visemes.length > 0 ? { visemes } : {}),\n ...(bookmarks.length > 0 ? { bookmarks } : {}),\n });\n };\n\n try {\n if (config.signal) {\n abortHandler = () => rejectWithError(\"Speech synthesis was cancelled.\");\n config.signal.addEventListener(\"abort\", abortHandler, { once: true });\n }\n if (config.timeoutMs !== undefined && config.timeoutMs > 0) {\n timeout = setTimeout(\n () => rejectWithError(`Speech synthesis timed out after ${config.timeoutMs} ms.`),\n config.timeoutMs,\n );\n }\n synthesizer.speakSsmlAsync(ssml, cb, rejectWithError);\n } catch (error) {\n rejectWithError(error);\n }\n });\n}\n\n/** Backward-compatible audio-only synthesis helper. */\nexport async function synthesizeSpeech(ssml: string, config: TtsConfig): Promise<ArrayBuffer> {\n return (await synthesizeSsml(ssml, config)).audioData;\n}\n","import { SpeechConfig } from \"microsoft-cognitiveservices-speech-sdk\";\nimport { DEFAULT_OUTPUT_FORMAT, resolveOutputFormat } from \"./outputFormats.ts\";\nimport type { TtsConfig } from \"./types.ts\";\n\nexport function resolveEndpoint(config: TtsConfig): string {\n const endpoint = config.endpoint?.trim() || \"https://{region}.tts.speech.microsoft.com/cognitiveservices/v1\";\n return endpoint.replace(/\\{region\\}/g, encodeURIComponent(config.region));\n}\n\nexport function createSpeechConfig(config: TtsConfig): SpeechConfig {\n const { outputFormat = DEFAULT_OUTPUT_FORMAT, subscriptionKey } = config;\n\n const endpoint = new URL(resolveEndpoint(config));\n const speechConfig = SpeechConfig.fromEndpoint(endpoint, subscriptionKey);\n speechConfig.speechSynthesisOutputFormat = resolveOutputFormat(outputFormat);\n return speechConfig;\n}\n","import * as SpeechSDK from \"microsoft-cognitiveservices-speech-sdk\";\n\nexport const DEFAULT_OUTPUT_FORMAT = \"audio-16khz-128kbitrate-mono-mp3\";\n\nconst OUTPUT_FORMATS: Record<string, SpeechSDK.SpeechSynthesisOutputFormat> = {\n \"raw-8khz-8bit-mono-mulaw\": SpeechSDK.SpeechSynthesisOutputFormat.Raw8Khz8BitMonoMULaw,\n \"riff-16khz-16kbps-mono-siren\": SpeechSDK.SpeechSynthesisOutputFormat.Riff16Khz16KbpsMonoSiren,\n \"audio-16khz-16kbps-mono-siren\": SpeechSDK.SpeechSynthesisOutputFormat.Audio16Khz16KbpsMonoSiren,\n \"audio-16khz-32kbitrate-mono-mp3\": SpeechSDK.SpeechSynthesisOutputFormat.Audio16Khz32KBitRateMonoMp3,\n \"audio-16khz-128kbitrate-mono-mp3\": SpeechSDK.SpeechSynthesisOutputFormat.Audio16Khz128KBitRateMonoMp3,\n \"audio-16khz-64kbitrate-mono-mp3\": SpeechSDK.SpeechSynthesisOutputFormat.Audio16Khz64KBitRateMonoMp3,\n \"audio-24khz-48kbitrate-mono-mp3\": SpeechSDK.SpeechSynthesisOutputFormat.Audio24Khz48KBitRateMonoMp3,\n \"audio-24khz-96kbitrate-mono-mp3\": SpeechSDK.SpeechSynthesisOutputFormat.Audio24Khz96KBitRateMonoMp3,\n \"audio-24khz-160kbitrate-mono-mp3\": SpeechSDK.SpeechSynthesisOutputFormat.Audio24Khz160KBitRateMonoMp3,\n \"raw-16khz-16bit-mono-truesilk\": SpeechSDK.SpeechSynthesisOutputFormat.Raw16Khz16BitMonoTrueSilk,\n \"riff-16khz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Riff16Khz16BitMonoPcm,\n \"riff-8khz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Riff8Khz16BitMonoPcm,\n \"riff-24khz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Riff24Khz16BitMonoPcm,\n \"riff-8khz-8bit-mono-mulaw\": SpeechSDK.SpeechSynthesisOutputFormat.Riff8Khz8BitMonoMULaw,\n \"raw-16khz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Raw16Khz16BitMonoPcm,\n \"raw-24khz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Raw24Khz16BitMonoPcm,\n \"raw-8khz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Raw8Khz16BitMonoPcm,\n \"ogg-16khz-16bit-mono-opus\": SpeechSDK.SpeechSynthesisOutputFormat.Ogg16Khz16BitMonoOpus,\n \"ogg-24khz-16bit-mono-opus\": SpeechSDK.SpeechSynthesisOutputFormat.Ogg24Khz16BitMonoOpus,\n \"raw-48khz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Raw48Khz16BitMonoPcm,\n \"riff-48khz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Riff48Khz16BitMonoPcm,\n \"audio-48khz-96kbitrate-mono-mp3\": SpeechSDK.SpeechSynthesisOutputFormat.Audio48Khz96KBitRateMonoMp3,\n \"audio-48khz-192kbitrate-mono-mp3\": SpeechSDK.SpeechSynthesisOutputFormat.Audio48Khz192KBitRateMonoMp3,\n \"ogg-48khz-16bit-mono-opus\": SpeechSDK.SpeechSynthesisOutputFormat.Ogg48Khz16BitMonoOpus,\n \"webm-16khz-16bit-mono-opus\": SpeechSDK.SpeechSynthesisOutputFormat.Webm16Khz16BitMonoOpus,\n \"webm-24khz-16bit-mono-opus\": SpeechSDK.SpeechSynthesisOutputFormat.Webm24Khz16BitMonoOpus,\n \"webm-24khz-16bit-24kbps-mono-opus\": SpeechSDK.SpeechSynthesisOutputFormat.Webm24Khz16Bit24KbpsMonoOpus,\n \"raw-24khz-16bit-mono-truesilk\": SpeechSDK.SpeechSynthesisOutputFormat.Raw24Khz16BitMonoTrueSilk,\n \"raw-8khz-8bit-mono-alaw\": SpeechSDK.SpeechSynthesisOutputFormat.Raw8Khz8BitMonoALaw,\n \"riff-8khz-8bit-mono-alaw\": SpeechSDK.SpeechSynthesisOutputFormat.Riff8Khz8BitMonoALaw,\n \"audio-16khz-16bit-32kbps-mono-opus\": SpeechSDK.SpeechSynthesisOutputFormat.Audio16Khz16Bit32KbpsMonoOpus,\n \"audio-24khz-16bit-48kbps-mono-opus\": SpeechSDK.SpeechSynthesisOutputFormat.Audio24Khz16Bit48KbpsMonoOpus,\n \"audio-24khz-16bit-24kbps-mono-opus\": SpeechSDK.SpeechSynthesisOutputFormat.Audio24Khz16Bit24KbpsMonoOpus,\n \"raw-22050hz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Raw22050Hz16BitMonoPcm,\n \"riff-22050hz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Riff22050Hz16BitMonoPcm,\n \"raw-44100hz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Raw44100Hz16BitMonoPcm,\n \"riff-44100hz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Riff44100Hz16BitMonoPcm,\n \"amr-wb-16000hz\": SpeechSDK.SpeechSynthesisOutputFormat.AmrWb16000Hz,\n \"g722-16khz-64kbps\": SpeechSDK.SpeechSynthesisOutputFormat.G72216Khz64Kbps,\n};\n\nexport function resolveOutputFormat(outputFormat: string): SpeechSDK.SpeechSynthesisOutputFormat {\n const resolvedFormat = OUTPUT_FORMATS[outputFormat];\n if (resolvedFormat === undefined) {\n throw new Error(`Unsupported Azure Speech output format: ${outputFormat}`);\n }\n\n return resolvedFormat;\n}\n","import { synthesizeSpeech, synthesizeSsml } from \"./synthesis.ts\";\nimport type { AzureTtsClientOptions, SsmlSynthesisResult } from \"./types.ts\";\n\nconst ENDPOINT_TEMPLATE = \"https://{region}.tts.speech.microsoft.com/cognitiveservices/v1\";\n\nexport class AzureTtsClient {\n readonly #options: AzureTtsClientOptions;\n\n constructor(options: AzureTtsClientOptions) {\n this.#options = options;\n }\n\n async synthesize(ssml: string): Promise<ArrayBuffer> {\n const { region, subscriptionKey, outputFormat, signal, timeoutMs } = this.#options;\n const endpoint = this.#options.endpoint?.trim() || ENDPOINT_TEMPLATE.replace(\"{region}\", region);\n this.#options.logger?.debug?.(\"Using Azure TTS endpoint:\", endpoint);\n\n const config = { endpoint, region, subscriptionKey, outputFormat, signal, timeoutMs };\n return synthesizeSpeech(ssml, config);\n }\n\n async synthesizeSsml(ssml: string): Promise<SsmlSynthesisResult> {\n const { region, subscriptionKey, outputFormat, signal, timeoutMs } = this.#options;\n const endpoint = this.#options.endpoint?.trim() || ENDPOINT_TEMPLATE.replace(\"{region}\", region);\n this.#options.logger?.debug?.(\"Using Azure TTS endpoint:\", endpoint);\n\n return synthesizeSsml(ssml, { endpoint, region, subscriptionKey, outputFormat, signal, timeoutMs });\n }\n}\n","const AZURE_VOICE_API_VERSION = \"2025-10-01\";\n\nexport interface FetchAzureVoiceCatalogOptions {\n apiKey: string;\n region: string | string[];\n}\n\nexport interface AzureVoiceCatalogVoice {\n name: string;\n locale: string;\n secondaryLocales?: readonly string[];\n styles?: readonly string[];\n regions: readonly string[];\n status?: \"ga\" | \"preview\" | \"deprecated\";\n}\n\nexport interface FetchedAzureVoiceCatalogMetadata {\n voiceCount: number;\n generatedAt: string;\n apiVersion: string;\n regions: readonly string[];\n}\n\nexport interface AzureVoiceCatalog {\n voices: readonly AzureVoiceCatalogVoice[];\n metadata: FetchedAzureVoiceCatalogMetadata;\n}\n\ninterface AzureVoiceApiRecord {\n Locale?: unknown;\n Name?: unknown;\n SecondaryLocaleList?: unknown;\n ShortName?: unknown;\n Status?: unknown;\n StyleList?: unknown;\n}\n\nfunction stringValue(value: unknown): string | undefined {\n return typeof value === \"string\" && value.trim() ? value.trim() : undefined;\n}\n\nfunction stringList(value: unknown): string[] {\n if (!Array.isArray(value)) return [];\n return [...new Set(value.map(stringValue).filter((item): item is string => item !== undefined))];\n}\n\nfunction normalizeStatus(value: unknown): AzureVoiceCatalogVoice[\"status\"] {\n const status = stringValue(value)?.toLowerCase();\n if (status === \"preview\" || status === \"deprecated\" || status === \"ga\") return status;\n return undefined;\n}\n\nfunction normalizeRegions(region: string | string[]): string[] {\n const regions = Array.isArray(region) ? region : [region];\n const result = [...new Set(regions.map((item) => item.trim()).filter(Boolean))];\n if (result.length === 0) throw new TypeError(\"At least one Azure Speech region is required.\");\n return result;\n}\n\nasync function fetchRegionVoices(region: string, apiKey: string): Promise<AzureVoiceApiRecord[]> {\n const endpoint = `https://${encodeURIComponent(region)}.tts.speech.microsoft.com/cognitiveservices/voices/list`;\n const response = await fetch(endpoint, {\n headers: {\n Accept: \"application/json\",\n \"Ocp-Apim-Subscription-Key\": apiKey,\n },\n });\n if (!response.ok) {\n throw new Error(`Azure List Voices API request failed for region \"${region}\" with HTTP ${response.status}.`);\n }\n const payload: unknown = await response.json();\n if (!Array.isArray(payload)) throw new Error(`Azure List Voices API returned an invalid response for \"${region}\".`);\n return payload.filter((item): item is AzureVoiceApiRecord => Boolean(item && typeof item === \"object\"));\n}\n\n/** Fetches and deduplicates the current Azure Speech voice catalog for one or more regions. */\nexport async function fetchAzureVoiceCatalog(options: FetchAzureVoiceCatalogOptions): Promise<AzureVoiceCatalog> {\n if (!options || typeof options.apiKey !== \"string\" || !options.apiKey.trim())\n throw new TypeError(\"An Azure Speech API key is required.\");\n const regions = normalizeRegions(options.region);\n const payloads = await Promise.all(regions.map((region) => fetchRegionVoices(region, options.apiKey)));\n const voices = new Map<string, AzureVoiceCatalogVoice>();\n\n for (let regionIndex = 0; regionIndex < payloads.length; regionIndex += 1) {\n const region = regions[regionIndex];\n for (const record of payloads[regionIndex]) {\n const name = stringValue(record.ShortName) ?? stringValue(record.Name);\n const locale = stringValue(record.Locale);\n if (!name || !locale) continue;\n const key = name.toLowerCase();\n const existing = voices.get(key);\n const secondaryLocales = stringList(record.SecondaryLocaleList);\n const styles = stringList(record.StyleList);\n const status = normalizeStatus(record.Status);\n const merged: AzureVoiceCatalogVoice = {\n name: existing?.name ?? name,\n locale: existing?.locale ?? locale,\n regions: [...new Set([...(existing?.regions ?? []), region])],\n };\n const mergedSecondaryLocales = [...new Set([...(existing?.secondaryLocales ?? []), ...secondaryLocales])];\n if (mergedSecondaryLocales.length > 0) merged.secondaryLocales = mergedSecondaryLocales;\n const mergedStyles = [...new Set([...(existing?.styles ?? []), ...styles])];\n if (mergedStyles.length > 0) merged.styles = mergedStyles;\n if (status) merged.status = status;\n else if (existing?.status) merged.status = existing.status;\n voices.set(key, merged);\n }\n }\n\n const sortedVoices = [...voices.values()].sort((first, second) => first.name.localeCompare(second.name));\n return {\n voices: sortedVoices,\n metadata: {\n voiceCount: sortedVoices.length,\n generatedAt: new Date().toISOString(),\n apiVersion: AZURE_VOICE_API_VERSION,\n regions,\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,gBAAN,cAA4B,MAAM;AAAA,EAMvC,YAAY,QAAgB,YAAoB,cAAsB,WAA0B;AAC9F,UAAM,6BAA6B,MAAM,IAAI,UAAU,EAAE;AACzD,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,aAAa;AAClB,SAAK,eAAe;AACpB,SAAK,YAAY;AAAA,EACnB;AACF;AAEO,IAAM,mBAAN,cAA+B,cAAc;AAAA,EAGlD,YA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Q;AACtB,YAAM,MAAM,KAAK,YAAY;AAC7B,YAAM,WAAW,OAAO,IAAI,GAAG;AAC/B,YAAM,mBAAmB,WAAW,OAAO,mBAAmB;AAC9D,YAAM,SAAS,WAAW,OAAO,SAAS;AAC1C,YAAM,SAAS,gBAAgB,OAAO,MAAM;AAC5C,YAAM,SAAiC;AAAA,QACrC,MAAM,UAAU,QAAQ;AAAA,QACxB,QAAQ,UAAU,UAAU;AAAA,QAC5B,SAAS,CAAC,GAAG,oBAAI,IAAI,CAAC,GAAI,UAAU,WAAW,CAAC,GAAI,MAAM,CAAC,CAAC;AAAA,MAC9D;AACA,YAAM,yBAAyB,CAAC,GAAG,oBAAI,IAAI,CAAC,GAAI,UAAU,oBAAoB,CAAC,GAAI,GAAG,gBAAgB,CAAC,CAAC;AACxG,UAAI,uBAAuB,SAAS,EAAG,QAAO,mBAAmB;AACjE,YAAM,eAAe,CAAC,GAAG,oBAAI,IAAI,CAAC,GAAI,UAAU,UAAU,CAAC,GAAI,GAAG,MAAM,CAAC,CAAC;AAC1E,UAAI,aAAa,SAAS,EAAG,QAAO,SAAS;AAC7C,UAAI,OAAQ,QAAO,SAAS;AAAA,eACnB,UAAU,OAAQ,QAAO,SAAS,SAAS;AACpD,aAAO,IAAI,KAAK,MAAM;AAAA,IACxB;AAAA,EACF;AAEA,QAAM,eAAe,CAAC,GAAG,OAAO,OAAO,CAAC,EAAE,KAAK,CAAC,OAAO,WAAW,MAAM,KAAK,cAAc,OAAO,IAAI,CAAC;AACvG,SAAO;AAAA,IACL,QAAQ;AAAA,IACR,UAAU;AAAA,MACR,YAAY,aAAa;AAAA,MACzB,cAAa,oBAAI,KAAK,GAAE,YAAY;AAAA,MACpC,YAAY;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AACF;","names":["SpeechSDK"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/errors.ts","../src/synthesis.ts","../src/speechConfig.ts","../src/outputFormats.ts","../src/safe.ts","../src/client.ts","../src/voiceCatalog.ts"],"sourcesContent":["/**\n * azure-tts-client: Azure Text-to-Speech client for SSML playback.\n */\n\nexport type {\n AzureTtsClientOptions,\n AzureTtsLogger,\n SsmlSynthesisBookmark,\n SsmlSynthesisBoundary,\n SsmlSynthesisResult,\n SsmlSynthesisViseme,\n SsmlSynthesisChunk,\n SynthesisProgressEvent,\n SynthesizeChunksOptions,\n TtsConfig,\n} from \"./types.ts\";\nexport { AzureTtsError, AzureTtsSdkError } from \"./errors.ts\";\nexport { AzureTtsClient } from \"./client.ts\";\nexport { synthesizeSpeech } from \"./synthesis.ts\";\nexport { synthesizeSsml } from \"./synthesis.ts\";\nexport { mergeSynthesisResults, synthesizeSsmlChunks } from \"./synthesis.ts\";\nexport { synthesizeSsmlSafe } from \"./safe.ts\";\nexport type {\n AzureApiErrorResult,\n Result,\n SsmlSynthesisSafeResult,\n SsmlValidationError as AzureSsmlValidationError,\n Success,\n SynthesisResult,\n SynthesizeSsmlSafeOptions,\n ValidationErrorResult,\n} from \"./safe.ts\";\nexport { fetchAzureVoiceCatalog } from \"./voiceCatalog.ts\";\nexport type {\n AzureVoiceCatalog,\n AzureVoiceCatalogVoice,\n FetchedAzureVoiceCatalogMetadata,\n FetchAzureVoiceCatalogOptions,\n} from \"./voiceCatalog.ts\";\n","export class AzureTtsError extends Error {\n readonly status: number;\n readonly statusText: string;\n readonly responseBody: string;\n readonly requestId: string | null;\n\n constructor(status: number, statusText: string, responseBody: string, requestId: string | null) {\n super(`Azure TTS request failed: ${status} ${statusText}`);\n this.name = \"AzureTtsError\";\n this.status = status;\n this.statusText = statusText;\n this.responseBody = responseBody;\n this.requestId = requestId;\n }\n}\n\nexport class AzureTtsSdkError extends AzureTtsError {\n readonly errorDetails: string;\n\n constructor(errorDetails: string) {\n super(0, \"Speech SDK\", errorDetails, null);\n this.name = \"AzureTtsSdkError\";\n this.message = `Azure TTS synthesis failed: ${errorDetails}`;\n this.errorDetails = errorDetails;\n }\n}\n\nexport function createSpeechSdkError(error: unknown): AzureTtsSdkError {\n const message = error instanceof Error ? error.message : String(error);\n return new AzureTtsSdkError(message);\n}\n","import * as SpeechSDK from \"microsoft-cognitiveservices-speech-sdk\";\nimport { createSpeechSdkError } from \"./errors.ts\";\nimport { createSpeechConfig } from \"./speechConfig.ts\";\nimport type { SsmlSynthesisChunk, SsmlSynthesisResult, TtsConfig } from \"./types.ts\";\n\nfunction closeSpeechResources(speechConfig: SpeechSDK.SpeechConfig, synthesizer: SpeechSDK.SpeechSynthesizer): void {\n try {\n synthesizer.close();\n } catch {}\n\n try {\n speechConfig.close();\n } catch {}\n}\n\nconst ticksToMilliseconds = (ticks: number): number => Math.max(0, ticks) / 10_000;\n\nexport async function synthesizeSsml(ssml: string, config: TtsConfig): Promise<SsmlSynthesisResult> {\n if (config.signal?.aborted) {\n throw createSpeechSdkError(\"Speech synthesis was cancelled.\");\n }\n\n const speechConfig = createSpeechConfig(config);\n const synthesizer = new SpeechSDK.SpeechSynthesizer(speechConfig, null);\n\n return await new Promise<SsmlSynthesisResult>((resolve, reject) => {\n let resourcesClosed = false;\n let settled = false;\n let timeout: ReturnType<typeof setTimeout> | undefined;\n let abortHandler: (() => void) | undefined;\n const cleanup = () => {\n if (timeout) clearTimeout(timeout);\n if (abortHandler) config.signal?.removeEventListener(\"abort\", abortHandler);\n };\n const closeResources = () => {\n if (resourcesClosed) return;\n resourcesClosed = true;\n closeSpeechResources(speechConfig, synthesizer);\n };\n const rejectWithError = (error: unknown) => {\n if (settled) return;\n settled = true;\n cleanup();\n closeResources();\n reject(createSpeechSdkError(error));\n };\n\n const boundaries: SsmlSynthesisResult[\"boundaries\"] = [];\n const visemes: SsmlSynthesisResult[\"visemes\"] = [];\n const bookmarks: SsmlSynthesisResult[\"bookmarks\"] = [];\n synthesizer.wordBoundary = (_sender, event) => {\n boundaries.push({\n text: event.text,\n audioOffsetMs: ticksToMilliseconds(event.audioOffset),\n durationMs: ticksToMilliseconds(event.duration),\n });\n };\n synthesizer.visemeReceived = (_sender, event) => {\n visemes.push({ visemeId: event.visemeId, audioOffsetMs: ticksToMilliseconds(event.audioOffset) });\n };\n synthesizer.bookmarkReached = (_sender, event) => {\n bookmarks.push({ name: event.text, audioOffsetMs: ticksToMilliseconds(event.audioOffset) });\n };\n\n const cb = (result: SpeechSDK.SpeechSynthesisResult) => {\n if (settled) return;\n const { reason, errorDetails } = result;\n if (reason !== SpeechSDK.ResultReason.SynthesizingAudioCompleted) {\n const err = errorDetails || `Speech synthesis failed with reason ${reason}.`;\n rejectWithError(err);\n return;\n }\n settled = true;\n cleanup();\n closeResources();\n const eventDurationMs = Math.max(\n 0,\n ...(boundaries ?? []).map((boundary) => boundary.audioOffsetMs + boundary.durationMs),\n ...(visemes ?? []).map((viseme) => viseme.audioOffsetMs),\n ...(bookmarks ?? []).map((bookmark) => bookmark.audioOffsetMs),\n );\n const durationMs = result.audioDuration ? ticksToMilliseconds(result.audioDuration) : eventDurationMs;\n const requestId = (result as SpeechSDK.SpeechSynthesisResult & { resultId?: string }).resultId;\n const addSourceMetadata = <T extends { audioOffsetMs: number }>(event: T): T => ({\n ...event,\n ...(config.sourceTextRange ? { textRange: { ...config.sourceTextRange } } : {}),\n ...(requestId ? { requestId } : {}),\n });\n const sourceBoundaries = boundaries.map((boundary) => addSourceMetadata(boundary));\n const sourceVisemes = visemes.map((viseme) => addSourceMetadata(viseme));\n const sourceBookmarks = bookmarks.map((bookmark) => addSourceMetadata(bookmark));\n resolve({\n audioData: result.audioData,\n durationMs,\n ...(config.sourceTextRange ? { textRange: { ...config.sourceTextRange } } : {}),\n ...(requestId ? { requestId } : {}),\n ...(sourceBoundaries.length > 0\n ? { boundaries: sourceBoundaries, wordBoundary: sourceBoundaries, wordBoundaries: sourceBoundaries }\n : {}),\n ...(sourceVisemes.length > 0 ? { visemes: sourceVisemes } : {}),\n ...(sourceBookmarks.length > 0 ? { bookmarks: sourceBookmarks } : {}),\n });\n };\n\n try {\n if (config.signal) {\n abortHandler = () => rejectWithError(\"Speech synthesis was cancelled.\");\n config.signal.addEventListener(\"abort\", abortHandler, { once: true });\n }\n if (config.timeoutMs !== undefined && config.timeoutMs > 0) {\n timeout = setTimeout(\n () => rejectWithError(`Speech synthesis timed out after ${config.timeoutMs} ms.`),\n config.timeoutMs,\n );\n }\n synthesizer.speakSsmlAsync(ssml, cb, rejectWithError);\n } catch (error) {\n rejectWithError(error);\n }\n });\n}\n\n/** Synthesizes chunks sequentially, annotates synchronization events, and merges the results. */\nexport async function synthesizeSsmlChunks(\n chunks: readonly (SsmlSynthesisChunk | string)[],\n config: TtsConfig,\n): Promise<SsmlSynthesisResult> {\n const results: SsmlSynthesisResult[] = [];\n const totalChunks = chunks.length;\n for (const [index, chunk] of chunks.entries()) {\n const input = typeof chunk === \"string\" ? { ssml: chunk } : chunk;\n const result = await synthesizeSsml(input.ssml, {\n ...config,\n ...(input.originalTextRange ? { sourceTextRange: input.originalTextRange } : {}),\n onProgress: undefined,\n });\n results.push(result);\n config.onProgress?.({\n currentChunk: index + 1,\n totalChunks,\n percent: totalChunks === 0 ? 100 : Math.round(((index + 1) / totalChunks) * 100),\n });\n }\n return mergeSynthesisResults(results);\n}\n\n/** Concatenates audio buffers and shifts all synchronization events by prior chunk durations. */\nexport function mergeSynthesisResults(results: readonly SsmlSynthesisResult[]): SsmlSynthesisResult {\n const audioLength = results.reduce((total, result) => total + result.audioData.byteLength, 0);\n const audioData = new Uint8Array(audioLength);\n const boundaries: NonNullable<SsmlSynthesisResult[\"boundaries\"]> = [];\n const visemes: NonNullable<SsmlSynthesisResult[\"visemes\"]> = [];\n const bookmarks: NonNullable<SsmlSynthesisResult[\"bookmarks\"]> = [];\n let byteOffset = 0;\n let durationOffset = 0;\n\n for (const result of results) {\n audioData.set(new Uint8Array(result.audioData), byteOffset);\n byteOffset += result.audioData.byteLength;\n const chunkBoundaries =\n result.boundaries && result.boundaries.length > 0\n ? result.boundaries\n : (result.wordBoundary ?? result.wordBoundaries ?? []);\n for (const boundary of chunkBoundaries) {\n const textRange = boundary.textRange ?? result.textRange;\n const requestId = boundary.requestId ?? result.requestId;\n boundaries.push({\n ...boundary,\n audioOffsetMs: boundary.audioOffsetMs + durationOffset,\n ...(textRange ? { textRange: { ...textRange } } : {}),\n ...(requestId ? { requestId } : {}),\n });\n }\n for (const viseme of result.visemes ?? []) {\n const textRange = viseme.textRange ?? result.textRange;\n const requestId = viseme.requestId ?? result.requestId;\n visemes.push({\n ...viseme,\n audioOffsetMs: viseme.audioOffsetMs + durationOffset,\n ...(textRange ? { textRange: { ...textRange } } : {}),\n ...(requestId ? { requestId } : {}),\n });\n }\n for (const bookmark of result.bookmarks ?? []) {\n const textRange = bookmark.textRange ?? result.textRange;\n const requestId = bookmark.requestId ?? result.requestId;\n bookmarks.push({\n ...bookmark,\n audioOffsetMs: bookmark.audioOffsetMs + durationOffset,\n ...(textRange ? { textRange: { ...textRange } } : {}),\n ...(requestId ? { requestId } : {}),\n });\n }\n durationOffset += Math.max(0, result.durationMs);\n }\n\n return {\n audioData: audioData.buffer,\n durationMs: durationOffset,\n ...(boundaries.length > 0 ? { boundaries, wordBoundary: boundaries, wordBoundaries: boundaries } : {}),\n ...(visemes.length > 0 ? { visemes } : {}),\n ...(bookmarks.length > 0 ? { bookmarks } : {}),\n ...(results.length === 1 && results[0]?.requestId ? { requestId: results[0].requestId } : {}),\n ...(results.length === 1 && results[0]?.textRange ? { textRange: { ...results[0].textRange } } : {}),\n };\n}\n\n/** Backward-compatible audio-only synthesis helper. */\nexport async function synthesizeSpeech(ssml: string, config: TtsConfig): Promise<ArrayBuffer> {\n return (await synthesizeSsml(ssml, config)).audioData;\n}\n","import { SpeechConfig } from \"microsoft-cognitiveservices-speech-sdk\";\nimport { DEFAULT_OUTPUT_FORMAT, resolveOutputFormat } from \"./outputFormats.ts\";\nimport type { TtsConfig } from \"./types.ts\";\n\nexport function resolveEndpoint(config: TtsConfig): string {\n const endpoint = config.endpoint?.trim() || \"https://{region}.tts.speech.microsoft.com/cognitiveservices/v1\";\n return endpoint.replace(/\\{region\\}/g, encodeURIComponent(config.region));\n}\n\nexport function createSpeechConfig(config: TtsConfig): SpeechConfig {\n const { outputFormat = DEFAULT_OUTPUT_FORMAT, subscriptionKey } = config;\n\n const endpoint = new URL(resolveEndpoint(config));\n const speechConfig = SpeechConfig.fromEndpoint(endpoint, subscriptionKey);\n speechConfig.speechSynthesisOutputFormat = resolveOutputFormat(outputFormat);\n return speechConfig;\n}\n","import * as SpeechSDK from \"microsoft-cognitiveservices-speech-sdk\";\n\nexport const DEFAULT_OUTPUT_FORMAT = \"audio-16khz-128kbitrate-mono-mp3\";\n\nconst OUTPUT_FORMATS: Record<string, SpeechSDK.SpeechSynthesisOutputFormat> = {\n \"raw-8khz-8bit-mono-mulaw\": SpeechSDK.SpeechSynthesisOutputFormat.Raw8Khz8BitMonoMULaw,\n \"riff-16khz-16kbps-mono-siren\": SpeechSDK.SpeechSynthesisOutputFormat.Riff16Khz16KbpsMonoSiren,\n \"audio-16khz-16kbps-mono-siren\": SpeechSDK.SpeechSynthesisOutputFormat.Audio16Khz16KbpsMonoSiren,\n \"audio-16khz-32kbitrate-mono-mp3\": SpeechSDK.SpeechSynthesisOutputFormat.Audio16Khz32KBitRateMonoMp3,\n \"audio-16khz-128kbitrate-mono-mp3\": SpeechSDK.SpeechSynthesisOutputFormat.Audio16Khz128KBitRateMonoMp3,\n \"audio-16khz-64kbitrate-mono-mp3\": SpeechSDK.SpeechSynthesisOutputFormat.Audio16Khz64KBitRateMonoMp3,\n \"audio-24khz-48kbitrate-mono-mp3\": SpeechSDK.SpeechSynthesisOutputFormat.Audio24Khz48KBitRateMonoMp3,\n \"audio-24khz-96kbitrate-mono-mp3\": SpeechSDK.SpeechSynthesisOutputFormat.Audio24Khz96KBitRateMonoMp3,\n \"audio-24khz-160kbitrate-mono-mp3\": SpeechSDK.SpeechSynthesisOutputFormat.Audio24Khz160KBitRateMonoMp3,\n \"raw-16khz-16bit-mono-truesilk\": SpeechSDK.SpeechSynthesisOutputFormat.Raw16Khz16BitMonoTrueSilk,\n \"riff-16khz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Riff16Khz16BitMonoPcm,\n \"riff-8khz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Riff8Khz16BitMonoPcm,\n \"riff-24khz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Riff24Khz16BitMonoPcm,\n \"riff-8khz-8bit-mono-mulaw\": SpeechSDK.SpeechSynthesisOutputFormat.Riff8Khz8BitMonoMULaw,\n \"raw-16khz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Raw16Khz16BitMonoPcm,\n \"raw-24khz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Raw24Khz16BitMonoPcm,\n \"raw-8khz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Raw8Khz16BitMonoPcm,\n \"ogg-16khz-16bit-mono-opus\": SpeechSDK.SpeechSynthesisOutputFormat.Ogg16Khz16BitMonoOpus,\n \"ogg-24khz-16bit-mono-opus\": SpeechSDK.SpeechSynthesisOutputFormat.Ogg24Khz16BitMonoOpus,\n \"raw-48khz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Raw48Khz16BitMonoPcm,\n \"riff-48khz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Riff48Khz16BitMonoPcm,\n \"audio-48khz-96kbitrate-mono-mp3\": SpeechSDK.SpeechSynthesisOutputFormat.Audio48Khz96KBitRateMonoMp3,\n \"audio-48khz-192kbitrate-mono-mp3\": SpeechSDK.SpeechSynthesisOutputFormat.Audio48Khz192KBitRateMonoMp3,\n \"ogg-48khz-16bit-mono-opus\": SpeechSDK.SpeechSynthesisOutputFormat.Ogg48Khz16BitMonoOpus,\n \"webm-16khz-16bit-mono-opus\": SpeechSDK.SpeechSynthesisOutputFormat.Webm16Khz16BitMonoOpus,\n \"webm-24khz-16bit-mono-opus\": SpeechSDK.SpeechSynthesisOutputFormat.Webm24Khz16BitMonoOpus,\n \"webm-24khz-16bit-24kbps-mono-opus\": SpeechSDK.SpeechSynthesisOutputFormat.Webm24Khz16Bit24KbpsMonoOpus,\n \"raw-24khz-16bit-mono-truesilk\": SpeechSDK.SpeechSynthesisOutputFormat.Raw24Khz16BitMonoTrueSilk,\n \"raw-8khz-8bit-mono-alaw\": SpeechSDK.SpeechSynthesisOutputFormat.Raw8Khz8BitMonoALaw,\n \"riff-8khz-8bit-mono-alaw\": SpeechSDK.SpeechSynthesisOutputFormat.Riff8Khz8BitMonoALaw,\n \"audio-16khz-16bit-32kbps-mono-opus\": SpeechSDK.SpeechSynthesisOutputFormat.Audio16Khz16Bit32KbpsMonoOpus,\n \"audio-24khz-16bit-48kbps-mono-opus\": SpeechSDK.SpeechSynthesisOutputFormat.Audio24Khz16Bit48KbpsMonoOpus,\n \"audio-24khz-16bit-24kbps-mono-opus\": SpeechSDK.SpeechSynthesisOutputFormat.Audio24Khz16Bit24KbpsMonoOpus,\n \"raw-22050hz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Raw22050Hz16BitMonoPcm,\n \"riff-22050hz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Riff22050Hz16BitMonoPcm,\n \"raw-44100hz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Raw44100Hz16BitMonoPcm,\n \"riff-44100hz-16bit-mono-pcm\": SpeechSDK.SpeechSynthesisOutputFormat.Riff44100Hz16BitMonoPcm,\n \"amr-wb-16000hz\": SpeechSDK.SpeechSynthesisOutputFormat.AmrWb16000Hz,\n \"g722-16khz-64kbps\": SpeechSDK.SpeechSynthesisOutputFormat.G72216Khz64Kbps,\n};\n\nexport function resolveOutputFormat(outputFormat: string): SpeechSDK.SpeechSynthesisOutputFormat {\n const resolvedFormat = OUTPUT_FORMATS[outputFormat];\n if (resolvedFormat === undefined) {\n throw new Error(`Unsupported Azure Speech output format: ${outputFormat}`);\n }\n\n return resolvedFormat;\n}\n","import { validateAzureSsml, type AzureValidationOptions, type SsmlDiagnostic } from \"@ssml-builder-js/ssml-core\";\nimport { AzureTtsError, createSpeechSdkError } from \"./errors.ts\";\nimport type { AzureTtsClient } from \"./client.ts\";\nimport type { SsmlSynthesisResult } from \"./types.ts\";\n\nexport interface SsmlValidationError {\n readonly kind: \"validation\";\n readonly message: string;\n readonly diagnostics: readonly SsmlDiagnostic[];\n}\n\nexport type Result<T, E> =\n | { readonly ok: true; readonly success: true; readonly status: \"success\"; readonly value: T }\n | {\n readonly ok: false;\n readonly success: false;\n readonly status: \"validation-error\" | \"azure-api-error\";\n readonly error: E;\n };\n\nexport type SynthesisResult<T, E> = Result<T, E>;\n\nexport type Success<T> = Extract<Result<T, never>, { readonly ok: true }>;\nexport type ValidationErrorResult = Extract<\n Result<never, SsmlValidationError>,\n { readonly status: \"validation-error\" }\n>;\nexport type AzureApiErrorResult = Extract<Result<never, AzureTtsError>, { readonly status: \"azure-api-error\" }>;\n\nexport type SsmlSynthesisSafeResult =\n | Result<SsmlSynthesisResult, never>\n | Result<never, SsmlValidationError>\n | Result<never, AzureTtsError>;\n\nexport interface SynthesizeSsmlSafeOptions extends AzureValidationOptions {\n /** Optional nested form for callers that want to keep validation settings grouped. */\n validation?: AzureValidationOptions;\n}\n\ninterface SynthesisClient {\n synthesizeSsml(ssml: string): Promise<SsmlSynthesisResult>;\n}\n\n/** Validates SSML before invoking Azure and converts validation/API failures to one result shape. */\nexport async function synthesizeSsmlSafe(\n client: Pick<AzureTtsClient, \"synthesizeSsml\"> | SynthesisClient,\n ssml: string,\n options: SynthesizeSsmlSafeOptions = {},\n): Promise<SsmlSynthesisSafeResult> {\n const validationOptions = options.validation ?? options;\n const diagnostics = await Promise.resolve(validateAzureSsml(ssml, validationOptions));\n const errors = diagnostics.filter((diagnostic) => diagnostic.severity === \"error\");\n if (errors.length > 0) {\n return {\n ok: false,\n success: false,\n status: \"validation-error\",\n error: {\n kind: \"validation\",\n message: \"SSML validation failed; the Azure Speech API was not called.\",\n diagnostics: errors,\n },\n };\n }\n\n try {\n return { ok: true, success: true, status: \"success\", value: await client.synthesizeSsml(ssml) };\n } catch (error) {\n const azureError = error instanceof AzureTtsError ? error : createSpeechSdkError(error);\n return { ok: false, success: false, status: \"azure-api-error\", error: azureError };\n }\n}\n","import { synthesizeSpeech, synthesizeSsml, synthesizeSsmlChunks } from \"./synthesis.ts\";\nimport { synthesizeSsmlSafe } from \"./safe.ts\";\nimport type { SynthesizeSsmlSafeOptions } from \"./safe.ts\";\nimport type {\n AzureTtsClientOptions,\n SsmlSynthesisChunk,\n SsmlSynthesisResult,\n SynthesizeChunksOptions,\n} from \"./types.ts\";\n\nconst ENDPOINT_TEMPLATE = \"https://{region}.tts.speech.microsoft.com/cognitiveservices/v1\";\n\nexport class AzureTtsClient {\n readonly #options: AzureTtsClientOptions;\n\n constructor(options: AzureTtsClientOptions) {\n this.#options = options;\n }\n\n async synthesize(ssml: string): Promise<ArrayBuffer> {\n const { region, subscriptionKey, outputFormat, signal, timeoutMs } = this.#options;\n const endpoint = this.#options.endpoint?.trim() || ENDPOINT_TEMPLATE.replace(\"{region}\", region);\n this.#options.logger?.debug?.(\"Using Azure TTS endpoint:\", endpoint);\n\n const config = { endpoint, region, subscriptionKey, outputFormat, signal, timeoutMs };\n return synthesizeSpeech(ssml, config);\n }\n\n async synthesizeSsml(ssml: string): Promise<SsmlSynthesisResult> {\n const { region, subscriptionKey, outputFormat, signal, timeoutMs } = this.#options;\n const endpoint = this.#options.endpoint?.trim() || ENDPOINT_TEMPLATE.replace(\"{region}\", region);\n this.#options.logger?.debug?.(\"Using Azure TTS endpoint:\", endpoint);\n\n return synthesizeSsml(ssml, { endpoint, region, subscriptionKey, outputFormat, signal, timeoutMs });\n }\n\n async synthesizeChunks(\n chunks: readonly (SsmlSynthesisChunk | string)[],\n options: SynthesizeChunksOptions = {},\n ): Promise<SsmlSynthesisResult> {\n const { region, subscriptionKey, outputFormat, signal, timeoutMs } = this.#options;\n const endpoint = this.#options.endpoint?.trim() || ENDPOINT_TEMPLATE.replace(\"{region}\", region);\n return synthesizeSsmlChunks(chunks, {\n endpoint,\n region,\n subscriptionKey,\n outputFormat,\n signal,\n timeoutMs,\n onProgress: options.onProgress ?? this.#options.onProgress,\n });\n }\n\n async synthesizeSsmlSafe(ssml: string, options: SynthesizeSsmlSafeOptions = {}) {\n return synthesizeSsmlSafe(this, ssml, options);\n }\n}\n","const AZURE_VOICE_API_VERSION = \"2025-10-01\";\n\nexport interface FetchAzureVoiceCatalogOptions {\n apiKey: string;\n region: string | string[];\n}\n\nexport interface AzureVoiceCatalogVoice {\n name: string;\n locale: string;\n secondaryLocales?: readonly string[];\n styles?: readonly string[];\n regions: readonly string[];\n status?: \"ga\" | \"preview\" | \"deprecated\";\n}\n\nexport interface FetchedAzureVoiceCatalogMetadata {\n voiceCount: number;\n generatedAt: string;\n apiVersion: string;\n regions: readonly string[];\n}\n\nexport interface AzureVoiceCatalog {\n voices: readonly AzureVoiceCatalogVoice[];\n metadata: FetchedAzureVoiceCatalogMetadata;\n}\n\ninterface AzureVoiceApiRecord {\n Locale?: unknown;\n Name?: unknown;\n SecondaryLocaleList?: unknown;\n ShortName?: unknown;\n Status?: unknown;\n StyleList?: unknown;\n}\n\nfunction stringValue(value: unknown): string | undefined {\n return typeof value === \"string\" && value.trim() ? value.trim() : undefined;\n}\n\nfunction stringList(value: unknown): string[] {\n if (!Array.isArray(value)) return [];\n return [...new Set(value.map(stringValue).filter((item): item is string => item !== undefined))];\n}\n\nfunction normalizeStatus(value: unknown): AzureVoiceCatalogVoice[\"status\"] {\n const status = stringValue(value)?.toLowerCase();\n if (status === \"preview\" || status === \"deprecated\" || status === \"ga\") return status;\n return undefined;\n}\n\nfunction normalizeRegions(region: string | string[]): string[] {\n const regions = Array.isArray(region) ? region : [region];\n const result = [...new Set(regions.map((item) => item.trim()).filter(Boolean))];\n if (result.length === 0) throw new TypeError(\"At least one Azure Speech region is required.\");\n return result;\n}\n\nasync function fetchRegionVoices(region: string, apiKey: string): Promise<AzureVoiceApiRecord[]> {\n const endpoint = `https://${encodeURIComponent(region)}.tts.speech.microsoft.com/cognitiveservices/voices/list`;\n const response = await fetch(endpoint, {\n headers: {\n Accept: \"application/json\",\n \"Ocp-Apim-Subscription-Key\": apiKey,\n },\n });\n if (!response.ok) {\n throw new Error(`Azure List Voices API request failed for region \"${region}\" with HTTP ${response.status}.`);\n }\n const payload: unknown = await response.json();\n if (!Array.isArray(payload)) throw new Error(`Azure List Voices API returned an invalid response for \"${region}\".`);\n return payload.filter((item): item is AzureVoiceApiRecord => Boolean(item && typeof item === \"object\"));\n}\n\n/** Fetches and deduplicates the current Azure Speech voice catalog for one or more regions. */\nexport async function fetchAzureVoiceCatalog(options: FetchAzureVoiceCatalogOptions): Promise<AzureVoiceCatalog> {\n if (!options || typeof options.apiKey !== \"string\" || !options.apiKey.trim())\n throw new TypeError(\"An Azure Speech API key is required.\");\n const regions = normalizeRegions(options.region);\n const payloads = await Promise.all(regions.map((region) => fetchRegionVoices(region, options.apiKey)));\n const voices = new Map<string, AzureVoiceCatalogVoice>();\n\n for (let regionIndex = 0; regionIndex < payloads.length; regionIndex += 1) {\n const region = regions[regionIndex];\n for (const record of payloads[regionIndex]) {\n const name = stringValue(record.ShortName) ?? stringValue(record.Name);\n const locale = stringValue(record.Locale);\n if (!name || !locale) continue;\n const key = name.toLowerCase();\n const existing = voices.get(key);\n const secondaryLocales = stringList(record.SecondaryLocaleList);\n const styles = stringList(record.StyleList);\n const status = normalizeStatus(record.Status);\n const merged: AzureVoiceCatalogVoice = {\n name: existing?.name ?? name,\n locale: existing?.locale ?? locale,\n regions: [...new Set([...(existing?.regions ?? []), region])],\n };\n const mergedSecondaryLocales = [...new Set([...(existing?.secondaryLocales ?? []), ...secondaryLocales])];\n if (mergedSecondaryLocales.length > 0) merged.secondaryLocales = mergedSecondaryLocales;\n const mergedStyles = [...new Set([...(existing?.styles ?? []), ...styles])];\n if (mergedStyles.length > 0) merged.styles = mergedStyles;\n if (status) merged.status = status;\n else if (existing?.status) merged.status = existing.status;\n voices.set(key, merged);\n }\n }\n\n const sortedVoices = [...voices.values()].sort((first, second) => first.name.localeCompare(second.name));\n return {\n voices: sortedVoices,\n metadata: {\n voiceCount: sortedVoices.length,\n generatedAt: new Date().toISOString(),\n apiVersion: AZURE_VOICE_API_VERSION,\n regions,\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,gBAAN,cAA4B,MAAM;AAAA,EAMvC,YAAY,QAAgB,YAAoB,cAAsB,WAA0B;AAC9F,UAAM,6BAA6B,MAAM,IAAI,UAAU,EAAE;AACzD,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,aAAa;AAClB,SAAK,eAAe;AACpB,SAAK,YAAY;AAAA,EACnB;AACF;AAEO,IAAM,mBAAN,cAA+B,cAAc;AAAA,EAGlD,YAAY,cAAsB;AAChC,UAAM,GAAG,cAAc,cAAc,IAAI;AACzC,SAAK,OAAO;AACZ,SAAK,UAAU,+BAA+B,YAAY;AAC1D,SAAK,eAAe;AAAA,EACtB;AACF;AAEO,SAAS,qBAAqB,OAAkC;AACrE,QAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AACrE,SAAO,IAAI,iBAAiB,OAAO;AACrC;;;AC9BA,IAAAA,aAA2B;;;ACA3B,oDAA6B;;;ACA7B,gBAA2B;AAEpB,IAAM,wBAAwB;AAErC,IAAM,iBAAwE;AAAA,EAC5E,4BAAsC,sCAA4B;AAAA,EAClE,gCAA0C,sCAA4B;AAAA,EACtE,iCAA2C,sCAA4B;AAAA,EACvE,mCAA6C,sCAA4B;AAAA,EACzE,oCAA8C,sCAA4B;AAAA,EAC1E,mCAA6C,sCAA4B;AAAA,EACz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