@ssml-builder-js/azure-tts-client 2.5.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.
@@ -0,0 +1,61 @@
1
+ import assert from "node:assert/strict";
2
+ import test from "node:test";
3
+ import * as SpeechSDK from "microsoft-cognitiveservices-speech-sdk";
4
+ import { createSpeechConfig, resolveEndpoint } from "../src/speechConfig.ts";
5
+
6
+ test("replaces and URL-encodes every endpoint region placeholder", () => {
7
+ assert.equal(
8
+ resolveEndpoint({
9
+ endpoint: "https://{region}.example.test/{region}",
10
+ subscriptionKey: "subscription-key",
11
+ region: "japan east",
12
+ }),
13
+ "https://japan%20east.example.test/japan%20east",
14
+ );
15
+ });
16
+
17
+ test("falls back to the regional endpoint for empty endpoint values", () => {
18
+ assert.equal(
19
+ resolveEndpoint({
20
+ endpoint: " ",
21
+ subscriptionKey: "subscription-key",
22
+ region: "japaneast",
23
+ }),
24
+ "https://japaneast.tts.speech.microsoft.com/cognitiveservices/v1",
25
+ );
26
+ });
27
+
28
+ test("creates Speech SDK configuration with the default format", () => {
29
+ const speechConfig = createSpeechConfig({
30
+ endpoint: "https://speech.example.test/cognitiveservices/v1",
31
+ subscriptionKey: "subscription-key",
32
+ region: "japaneast",
33
+ });
34
+
35
+ try {
36
+ assert.equal(
37
+ speechConfig.speechSynthesisOutputFormat,
38
+ SpeechSDK.SpeechSynthesisOutputFormat.Audio16Khz128KBitRateMonoMp3,
39
+ );
40
+ } finally {
41
+ speechConfig.close();
42
+ }
43
+ });
44
+
45
+ test("creates Speech SDK configuration with a custom format", () => {
46
+ const speechConfig = createSpeechConfig({
47
+ endpoint: "https://speech.example.test/cognitiveservices/v1",
48
+ subscriptionKey: "subscription-key",
49
+ region: "japaneast",
50
+ outputFormat: "raw-22050hz-16bit-mono-pcm",
51
+ });
52
+
53
+ try {
54
+ assert.equal(
55
+ speechConfig.speechSynthesisOutputFormat,
56
+ SpeechSDK.SpeechSynthesisOutputFormat.Raw22050Hz16BitMonoPcm,
57
+ );
58
+ } finally {
59
+ speechConfig.close();
60
+ }
61
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "dist",
5
+ "rootDir": "src",
6
+ "rewriteRelativeImportExtensions": true
7
+ },
8
+ "include": ["src"]
9
+ }
package/tsup.config.ts ADDED
@@ -0,0 +1,14 @@
1
+ import { defineConfig } from "tsup";
2
+
3
+ export default defineConfig({
4
+ entry: ["src/index.ts"],
5
+ format: ["esm", "cjs"],
6
+ dts: {
7
+ compilerOptions: {
8
+ composite: false,
9
+ ignoreDeprecations: "6.0",
10
+ },
11
+ },
12
+ sourcemap: true,
13
+ clean: true,
14
+ });