@contractspec/example.voice-providers 1.57.0 → 1.58.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/.turbo/turbo-build.log +43 -46
- package/.turbo/turbo-prebuild.log +1 -0
- package/CHANGELOG.md +13 -0
- package/dist/browser/connection.sample.js +55 -0
- package/dist/browser/docs/index.js +36 -0
- package/dist/browser/docs/voice-providers.docblock.js +36 -0
- package/dist/browser/example.js +33 -0
- package/dist/browser/handlers/create-provider.js +35 -0
- package/dist/browser/handlers/list-voices.js +41 -0
- package/dist/browser/handlers/synthesize.js +41 -0
- package/dist/browser/index.js +171 -0
- package/dist/browser/run.js +179 -0
- package/dist/connection.sample.d.ts +4 -8
- package/dist/connection.sample.d.ts.map +1 -1
- package/dist/connection.sample.js +54 -49
- package/dist/docs/index.d.ts +2 -1
- package/dist/docs/index.d.ts.map +1 -0
- package/dist/docs/index.js +37 -1
- package/dist/docs/voice-providers.docblock.d.ts +2 -1
- package/dist/docs/voice-providers.docblock.d.ts.map +1 -0
- package/dist/docs/voice-providers.docblock.js +35 -29
- package/dist/example.d.ts +2 -6
- package/dist/example.d.ts.map +1 -1
- package/dist/example.js +32 -44
- package/dist/handlers/create-provider.d.ts +21 -25
- package/dist/handlers/create-provider.d.ts.map +1 -1
- package/dist/handlers/create-provider.js +32 -28
- package/dist/handlers/list-voices.d.ts +3 -7
- package/dist/handlers/list-voices.d.ts.map +1 -1
- package/dist/handlers/list-voices.js +39 -7
- package/dist/handlers/synthesize.d.ts +5 -9
- package/dist/handlers/synthesize.d.ts.map +1 -1
- package/dist/handlers/synthesize.js +39 -7
- package/dist/index.d.ts +7 -6
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +172 -8
- package/dist/node/connection.sample.js +55 -0
- package/dist/node/docs/index.js +36 -0
- package/dist/node/docs/voice-providers.docblock.js +36 -0
- package/dist/node/example.js +33 -0
- package/dist/node/handlers/create-provider.js +35 -0
- package/dist/node/handlers/list-voices.js +41 -0
- package/dist/node/handlers/synthesize.js +41 -0
- package/dist/node/index.js +171 -0
- package/dist/node/run.js +179 -0
- package/dist/run.d.ts +1 -4
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +160 -98
- package/package.json +93 -32
- package/tsdown.config.js +1 -2
- package/.turbo/turbo-build$colon$bundle.log +0 -46
- package/dist/connection.sample.js.map +0 -1
- package/dist/docs/voice-providers.docblock.js.map +0 -1
- package/dist/example.js.map +0 -1
- package/dist/handlers/create-provider.js.map +0 -1
- package/dist/handlers/list-voices.js.map +0 -1
- package/dist/handlers/synthesize.js.map +0 -1
- package/dist/run.js.map +0 -1
- package/tsconfig.tsbuildinfo +0 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,47 +1,44 @@
|
|
|
1
|
-
$ bun
|
|
2
|
-
$
|
|
3
|
-
$
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
[34mℹ[39m target: [34mesnext[39m
|
|
8
|
-
[34mℹ[39m tsconfig: [34mtsconfig.json[39m
|
|
9
|
-
[34mℹ[39m Build start
|
|
10
|
-
[34mℹ[39m [2mdist/[22m[1mrun.js[22m [2m3.90 kB[22m [2m│ gzip: 1.33 kB[22m
|
|
11
|
-
[34mℹ[39m [2mdist/[22m[1mdocs/voice-providers.docblock.js[22m [2m1.85 kB[22m [2m│ gzip: 0.87 kB[22m
|
|
12
|
-
[34mℹ[39m [2mdist/[22m[1mconnection.sample.js[22m [2m1.48 kB[22m [2m│ gzip: 0.58 kB[22m
|
|
13
|
-
[34mℹ[39m [2mdist/[22m[1mhandlers/create-provider.js[22m [2m1.21 kB[22m [2m│ gzip: 0.49 kB[22m
|
|
14
|
-
[34mℹ[39m [2mdist/[22m[1mexample.js[22m [2m0.99 kB[22m [2m│ gzip: 0.51 kB[22m
|
|
15
|
-
[34mℹ[39m [2mdist/[22m[1mindex.js[22m [2m0.49 kB[22m [2m│ gzip: 0.20 kB[22m
|
|
16
|
-
[34mℹ[39m [2mdist/[22m[1mhandlers/synthesize.js[22m [2m0.28 kB[22m [2m│ gzip: 0.19 kB[22m
|
|
17
|
-
[34mℹ[39m [2mdist/[22m[1mhandlers/list-voices.js[22m [2m0.26 kB[22m [2m│ gzip: 0.18 kB[22m
|
|
18
|
-
[34mℹ[39m [2mdist/[22m[1mdocs/index.js[22m [2m0.04 kB[22m [2m│ gzip: 0.06 kB[22m
|
|
19
|
-
[34mℹ[39m [2mdist/[22mrun.js.map [2m7.18 kB[22m [2m│ gzip: 2.33 kB[22m
|
|
20
|
-
[34mℹ[39m [2mdist/[22mhandlers/create-provider.js.map [2m2.73 kB[22m [2m│ gzip: 0.96 kB[22m
|
|
21
|
-
[34mℹ[39m [2mdist/[22mdocs/voice-providers.docblock.js.map [2m2.57 kB[22m [2m│ gzip: 1.08 kB[22m
|
|
22
|
-
[34mℹ[39m [2mdist/[22mconnection.sample.js.map [2m2.28 kB[22m [2m│ gzip: 0.83 kB[22m
|
|
23
|
-
[34mℹ[39m [2mdist/[22mexample.js.map [2m1.46 kB[22m [2m│ gzip: 0.70 kB[22m
|
|
24
|
-
[34mℹ[39m [2mdist/[22mhandlers/synthesize.js.map [2m0.76 kB[22m [2m│ gzip: 0.40 kB[22m
|
|
25
|
-
[34mℹ[39m [2mdist/[22mhandlers/list-voices.js.map [2m0.56 kB[22m [2m│ gzip: 0.34 kB[22m
|
|
26
|
-
[34mℹ[39m [2mdist/[22mhandlers/create-provider.d.ts.map [2m0.43 kB[22m [2m│ gzip: 0.24 kB[22m
|
|
27
|
-
[34mℹ[39m [2mdist/[22mhandlers/synthesize.d.ts.map [2m0.22 kB[22m [2m│ gzip: 0.18 kB[22m
|
|
28
|
-
[34mℹ[39m [2mdist/[22mconnection.sample.d.ts.map [2m0.20 kB[22m [2m│ gzip: 0.14 kB[22m
|
|
29
|
-
[34mℹ[39m [2mdist/[22mhandlers/list-voices.d.ts.map [2m0.17 kB[22m [2m│ gzip: 0.15 kB[22m
|
|
30
|
-
[34mℹ[39m [2mdist/[22mexample.d.ts.map [2m0.13 kB[22m [2m│ gzip: 0.13 kB[22m
|
|
31
|
-
[34mℹ[39m [2mdist/[22mrun.d.ts.map [2m0.12 kB[22m [2m│ gzip: 0.13 kB[22m
|
|
32
|
-
[34mℹ[39m [2mdist/[22m[32m[1mhandlers/create-provider.d.ts[22m[39m [2m1.05 kB[22m [2m│ gzip: 0.45 kB[22m
|
|
33
|
-
[34mℹ[39m [2mdist/[22m[32m[1mindex.d.ts[22m[39m [2m0.69 kB[22m [2m│ gzip: 0.24 kB[22m
|
|
34
|
-
[34mℹ[39m [2mdist/[22m[32m[1mhandlers/synthesize.d.ts[22m[39m [2m0.52 kB[22m [2m│ gzip: 0.27 kB[22m
|
|
35
|
-
[34mℹ[39m [2mdist/[22m[32m[1mconnection.sample.d.ts[22m[39m [2m0.45 kB[22m [2m│ gzip: 0.21 kB[22m
|
|
36
|
-
[34mℹ[39m [2mdist/[22m[32m[1mhandlers/list-voices.d.ts[22m[39m [2m0.35 kB[22m [2m│ gzip: 0.23 kB[22m
|
|
37
|
-
[34mℹ[39m [2mdist/[22m[32m[1mexample.d.ts[22m[39m [2m0.25 kB[22m [2m│ gzip: 0.17 kB[22m
|
|
38
|
-
[34mℹ[39m [2mdist/[22m[32m[1mrun.d.ts[22m[39m [2m0.20 kB[22m [2m│ gzip: 0.16 kB[22m
|
|
39
|
-
[34mℹ[39m [2mdist/[22m[32m[1mdocs/index.d.ts[22m[39m [2m0.01 kB[22m [2m│ gzip: 0.03 kB[22m
|
|
40
|
-
[34mℹ[39m [2mdist/[22m[32m[1mdocs/voice-providers.docblock.d.ts[22m[39m [2m0.01 kB[22m [2m│ gzip: 0.03 kB[22m
|
|
41
|
-
[34mℹ[39m 31 files, total: 32.86 kB
|
|
42
|
-
[33m[PLUGIN_TIMINGS] Warning:[0m Your build spent significant time in plugins. Here is a breakdown:
|
|
43
|
-
- tsdown:external (56%)
|
|
44
|
-
- rolldown-plugin-dts:generate (42%)
|
|
45
|
-
See https://rolldown.rs/options/checks#plugintimings for more details.
|
|
1
|
+
$ contractspec-bun-build prebuild
|
|
2
|
+
$ bun run prebuild && bun run build:bundle && bun run build:types
|
|
3
|
+
$ contractspec-bun-build prebuild
|
|
4
|
+
$ contractspec-bun-build transpile
|
|
5
|
+
[contractspec-bun-build] transpile target=bun root=src entries=9
|
|
6
|
+
Bundled 9 modules in 40ms
|
|
46
7
|
|
|
47
|
-
|
|
8
|
+
./connection.sample.js 1.50 KB (entry point)
|
|
9
|
+
./run.js 5.59 KB (entry point)
|
|
10
|
+
./index.js 5.98 KB (entry point)
|
|
11
|
+
docs/index.js 1.92 KB (entry point)
|
|
12
|
+
docs/voice-providers.docblock.js 1.92 KB (entry point)
|
|
13
|
+
./example.js 0.99 KB (entry point)
|
|
14
|
+
handlers/list-voices.js 1.40 KB (entry point)
|
|
15
|
+
handlers/synthesize.js 1.43 KB (entry point)
|
|
16
|
+
handlers/create-provider.js 1.27 KB (entry point)
|
|
17
|
+
|
|
18
|
+
[contractspec-bun-build] transpile target=node root=src entries=9
|
|
19
|
+
Bundled 9 modules in 31ms
|
|
20
|
+
|
|
21
|
+
./connection.sample.js 1.49 KB (entry point)
|
|
22
|
+
./run.js 5.58 KB (entry point)
|
|
23
|
+
./index.js 5.97 KB (entry point)
|
|
24
|
+
docs/index.js 1.91 KB (entry point)
|
|
25
|
+
docs/voice-providers.docblock.js 1.91 KB (entry point)
|
|
26
|
+
./example.js 0.98 KB (entry point)
|
|
27
|
+
handlers/list-voices.js 1.40 KB (entry point)
|
|
28
|
+
handlers/synthesize.js 1.42 KB (entry point)
|
|
29
|
+
handlers/create-provider.js 1.26 KB (entry point)
|
|
30
|
+
|
|
31
|
+
[contractspec-bun-build] transpile target=browser root=src entries=9
|
|
32
|
+
Bundled 9 modules in 26ms
|
|
33
|
+
|
|
34
|
+
./connection.sample.js 1.49 KB (entry point)
|
|
35
|
+
./run.js 5.58 KB (entry point)
|
|
36
|
+
./index.js 5.97 KB (entry point)
|
|
37
|
+
docs/index.js 1.91 KB (entry point)
|
|
38
|
+
docs/voice-providers.docblock.js 1.91 KB (entry point)
|
|
39
|
+
./example.js 0.98 KB (entry point)
|
|
40
|
+
handlers/list-voices.js 1.40 KB (entry point)
|
|
41
|
+
handlers/synthesize.js 1.42 KB (entry point)
|
|
42
|
+
handlers/create-provider.js 1.26 KB (entry point)
|
|
43
|
+
|
|
44
|
+
$ contractspec-bun-build types
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
$ contractspec-bun-build prebuild
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @contractspec/example.voice-providers
|
|
2
2
|
|
|
3
|
+
## 1.58.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- d1f0fd0: chore: Migrate non-app package builds from tsdown to shared Bun tooling, add `@contractspec/tool.bun`, and standardize `prebuild`/`build`/`typecheck` with platform-aware exports and `tsc` declaration emission into `dist`.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [d1f0fd0]
|
|
12
|
+
- Updated dependencies [4355a9e]
|
|
13
|
+
- @contractspec/integration.providers-impls@1.58.0
|
|
14
|
+
- @contractspec/lib.contracts@1.58.0
|
|
15
|
+
|
|
3
16
|
## 1.57.0
|
|
4
17
|
|
|
5
18
|
### Minor Changes
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// src/connection.sample.ts
|
|
2
|
+
var gradiumVoiceConnection = {
|
|
3
|
+
meta: {
|
|
4
|
+
id: "conn-gradium-voice-demo",
|
|
5
|
+
tenantId: "acme-inc",
|
|
6
|
+
integrationKey: "ai-voice.gradium",
|
|
7
|
+
integrationVersion: "1.0.0",
|
|
8
|
+
label: "Gradium Voice",
|
|
9
|
+
environment: "production",
|
|
10
|
+
createdAt: "2026-01-01T00:00:00.000Z",
|
|
11
|
+
updatedAt: "2026-01-01T00:00:00.000Z"
|
|
12
|
+
},
|
|
13
|
+
ownershipMode: "byok",
|
|
14
|
+
config: {
|
|
15
|
+
defaultVoiceId: "YTpq7expH9539ERJ",
|
|
16
|
+
region: "eu",
|
|
17
|
+
outputFormat: "wav"
|
|
18
|
+
},
|
|
19
|
+
secretProvider: "vault",
|
|
20
|
+
secretRef: "vault://integrations/acme-inc/conn-gradium-voice-demo",
|
|
21
|
+
status: "connected"
|
|
22
|
+
};
|
|
23
|
+
var falVoiceConnection = {
|
|
24
|
+
meta: {
|
|
25
|
+
id: "conn-fal-voice-demo",
|
|
26
|
+
tenantId: "acme-inc",
|
|
27
|
+
integrationKey: "ai-voice.fal",
|
|
28
|
+
integrationVersion: "1.0.0",
|
|
29
|
+
label: "Fal Voice",
|
|
30
|
+
environment: "production",
|
|
31
|
+
createdAt: "2026-01-01T00:00:00.000Z",
|
|
32
|
+
updatedAt: "2026-01-01T00:00:00.000Z"
|
|
33
|
+
},
|
|
34
|
+
ownershipMode: "byok",
|
|
35
|
+
config: {
|
|
36
|
+
modelId: "fal-ai/chatterbox/text-to-speech",
|
|
37
|
+
defaultVoiceUrl: "https://storage.googleapis.com/chatterbox-demo-samples/prompts/male_rickmorty.mp3",
|
|
38
|
+
defaultExaggeration: 0.25,
|
|
39
|
+
defaultTemperature: 0.7,
|
|
40
|
+
defaultCfg: 0.5,
|
|
41
|
+
pollIntervalMs: 1000
|
|
42
|
+
},
|
|
43
|
+
secretProvider: "vault",
|
|
44
|
+
secretRef: "vault://integrations/acme-inc/conn-fal-voice-demo",
|
|
45
|
+
status: "connected"
|
|
46
|
+
};
|
|
47
|
+
var voiceSampleConnections = [
|
|
48
|
+
gradiumVoiceConnection,
|
|
49
|
+
falVoiceConnection
|
|
50
|
+
];
|
|
51
|
+
export {
|
|
52
|
+
voiceSampleConnections,
|
|
53
|
+
gradiumVoiceConnection,
|
|
54
|
+
falVoiceConnection
|
|
55
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// src/docs/voice-providers.docblock.ts
|
|
2
|
+
import { registerDocBlocks } from "@contractspec/lib.contracts/docs";
|
|
3
|
+
var blocks = [
|
|
4
|
+
{
|
|
5
|
+
id: "docs.examples.voice-providers",
|
|
6
|
+
title: "Voice Providers (example)",
|
|
7
|
+
summary: "Multi-provider voice integration example covering Gradium and Fal text-to-speech flows.",
|
|
8
|
+
kind: "reference",
|
|
9
|
+
visibility: "public",
|
|
10
|
+
route: "/docs/examples/voice-providers",
|
|
11
|
+
tags: ["voice", "tts", "gradium", "fal", "example"],
|
|
12
|
+
body: `## What this example shows
|
|
13
|
+
` + "- Provider selection for `ai-voice.gradium` and `ai-voice.fal`.\n" + `- Listing voice catalogs and synthesizing text into audio bytes.
|
|
14
|
+
` + `- Connection metadata patterns for BYOK secret references.
|
|
15
|
+
|
|
16
|
+
` + `## Secrets and config
|
|
17
|
+
` + "- `apiKey` for each provider.\n" + "- Gradium config: `defaultVoiceId`, `region`, `outputFormat`.\n" + "- Fal config: `modelId`, `defaultVoiceUrl`, synthesis tuning fields.\n\n" + `## Guardrails
|
|
18
|
+
` + `- Keep API keys in secret providers only.
|
|
19
|
+
` + `- Prefer declarative provider config over hardcoded runtime options.
|
|
20
|
+
` + "- Keep synthesis side effects explicit for deterministic workflows."
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: "docs.examples.voice-providers.usage",
|
|
24
|
+
title: "Voice Providers - Usage",
|
|
25
|
+
summary: "How to wire provider factory and synthesis helpers in runtime code.",
|
|
26
|
+
kind: "usage",
|
|
27
|
+
visibility: "public",
|
|
28
|
+
route: "/docs/examples/voice-providers/usage",
|
|
29
|
+
tags: ["voice", "usage"],
|
|
30
|
+
body: `## Usage
|
|
31
|
+
` + "- Call `createVoiceProvider` with integration key, secrets, and config.\n" + "- Use `listVoices` to expose voice choices in admin/config screens.\n" + "- Use `synthesizeVoice` for message generation or workflow steps.\n\n" + `## Notes
|
|
32
|
+
` + `- Fal uses an audio URL output; this example downloads bytes for a canonical result shape.
|
|
33
|
+
` + "- Gradium maps provider output formats into ContractSpec voice result conventions."
|
|
34
|
+
}
|
|
35
|
+
];
|
|
36
|
+
registerDocBlocks(blocks);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// src/docs/voice-providers.docblock.ts
|
|
2
|
+
import { registerDocBlocks } from "@contractspec/lib.contracts/docs";
|
|
3
|
+
var blocks = [
|
|
4
|
+
{
|
|
5
|
+
id: "docs.examples.voice-providers",
|
|
6
|
+
title: "Voice Providers (example)",
|
|
7
|
+
summary: "Multi-provider voice integration example covering Gradium and Fal text-to-speech flows.",
|
|
8
|
+
kind: "reference",
|
|
9
|
+
visibility: "public",
|
|
10
|
+
route: "/docs/examples/voice-providers",
|
|
11
|
+
tags: ["voice", "tts", "gradium", "fal", "example"],
|
|
12
|
+
body: `## What this example shows
|
|
13
|
+
` + "- Provider selection for `ai-voice.gradium` and `ai-voice.fal`.\n" + `- Listing voice catalogs and synthesizing text into audio bytes.
|
|
14
|
+
` + `- Connection metadata patterns for BYOK secret references.
|
|
15
|
+
|
|
16
|
+
` + `## Secrets and config
|
|
17
|
+
` + "- `apiKey` for each provider.\n" + "- Gradium config: `defaultVoiceId`, `region`, `outputFormat`.\n" + "- Fal config: `modelId`, `defaultVoiceUrl`, synthesis tuning fields.\n\n" + `## Guardrails
|
|
18
|
+
` + `- Keep API keys in secret providers only.
|
|
19
|
+
` + `- Prefer declarative provider config over hardcoded runtime options.
|
|
20
|
+
` + "- Keep synthesis side effects explicit for deterministic workflows."
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: "docs.examples.voice-providers.usage",
|
|
24
|
+
title: "Voice Providers - Usage",
|
|
25
|
+
summary: "How to wire provider factory and synthesis helpers in runtime code.",
|
|
26
|
+
kind: "usage",
|
|
27
|
+
visibility: "public",
|
|
28
|
+
route: "/docs/examples/voice-providers/usage",
|
|
29
|
+
tags: ["voice", "usage"],
|
|
30
|
+
body: `## Usage
|
|
31
|
+
` + "- Call `createVoiceProvider` with integration key, secrets, and config.\n" + "- Use `listVoices` to expose voice choices in admin/config screens.\n" + "- Use `synthesizeVoice` for message generation or workflow steps.\n\n" + `## Notes
|
|
32
|
+
` + `- Fal uses an audio URL output; this example downloads bytes for a canonical result shape.
|
|
33
|
+
` + "- Gradium maps provider output formats into ContractSpec voice result conventions."
|
|
34
|
+
}
|
|
35
|
+
];
|
|
36
|
+
registerDocBlocks(blocks);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// src/example.ts
|
|
2
|
+
import { defineExample } from "@contractspec/lib.contracts";
|
|
3
|
+
var example = defineExample({
|
|
4
|
+
meta: {
|
|
5
|
+
key: "voice-providers",
|
|
6
|
+
version: "1.0.0",
|
|
7
|
+
title: "Voice Providers (Gradium and Fal)",
|
|
8
|
+
description: "Multi-provider voice integration example for Gradium and Fal text-to-speech adapters.",
|
|
9
|
+
kind: "integration",
|
|
10
|
+
visibility: "public",
|
|
11
|
+
stability: "experimental",
|
|
12
|
+
owners: ["@platform.integrations"],
|
|
13
|
+
tags: ["voice", "tts", "gradium", "fal", "integrations"]
|
|
14
|
+
},
|
|
15
|
+
docs: {
|
|
16
|
+
rootDocId: "docs.examples.voice-providers",
|
|
17
|
+
usageDocId: "docs.examples.voice-providers.usage"
|
|
18
|
+
},
|
|
19
|
+
entrypoints: {
|
|
20
|
+
packageName: "@contractspec/example.voice-providers",
|
|
21
|
+
docs: "./docs"
|
|
22
|
+
},
|
|
23
|
+
surfaces: {
|
|
24
|
+
templates: true,
|
|
25
|
+
sandbox: { enabled: true, modes: ["markdown", "specs"] },
|
|
26
|
+
studio: { enabled: true, installable: true },
|
|
27
|
+
mcp: { enabled: true }
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
var example_default = example;
|
|
31
|
+
export {
|
|
32
|
+
example_default as default
|
|
33
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// src/handlers/create-provider.ts
|
|
2
|
+
import { FalVoiceProvider } from "@contractspec/integration.providers-impls/impls/fal-voice";
|
|
3
|
+
import { GradiumVoiceProvider } from "@contractspec/integration.providers-impls/impls/gradium-voice";
|
|
4
|
+
function createVoiceProvider(input) {
|
|
5
|
+
const { integrationKey, secrets, config } = input;
|
|
6
|
+
if (!secrets.apiKey) {
|
|
7
|
+
throw new Error("Voice provider apiKey is required.");
|
|
8
|
+
}
|
|
9
|
+
switch (integrationKey) {
|
|
10
|
+
case "ai-voice.gradium":
|
|
11
|
+
return new GradiumVoiceProvider({
|
|
12
|
+
apiKey: secrets.apiKey,
|
|
13
|
+
defaultVoiceId: config?.defaultVoiceId,
|
|
14
|
+
region: config?.region,
|
|
15
|
+
baseUrl: config?.baseUrl,
|
|
16
|
+
timeoutMs: config?.timeoutMs,
|
|
17
|
+
outputFormat: config?.outputFormat
|
|
18
|
+
});
|
|
19
|
+
case "ai-voice.fal":
|
|
20
|
+
return new FalVoiceProvider({
|
|
21
|
+
apiKey: secrets.apiKey,
|
|
22
|
+
modelId: config?.modelId,
|
|
23
|
+
defaultVoiceUrl: config?.defaultVoiceUrl,
|
|
24
|
+
defaultExaggeration: config?.defaultExaggeration,
|
|
25
|
+
defaultTemperature: config?.defaultTemperature,
|
|
26
|
+
defaultCfg: config?.defaultCfg,
|
|
27
|
+
pollIntervalMs: config?.pollIntervalMs
|
|
28
|
+
});
|
|
29
|
+
default:
|
|
30
|
+
throw new Error(`Unsupported voice provider: ${integrationKey}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
createVoiceProvider
|
|
35
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// src/handlers/create-provider.ts
|
|
2
|
+
import { FalVoiceProvider } from "@contractspec/integration.providers-impls/impls/fal-voice";
|
|
3
|
+
import { GradiumVoiceProvider } from "@contractspec/integration.providers-impls/impls/gradium-voice";
|
|
4
|
+
function createVoiceProvider(input) {
|
|
5
|
+
const { integrationKey, secrets, config } = input;
|
|
6
|
+
if (!secrets.apiKey) {
|
|
7
|
+
throw new Error("Voice provider apiKey is required.");
|
|
8
|
+
}
|
|
9
|
+
switch (integrationKey) {
|
|
10
|
+
case "ai-voice.gradium":
|
|
11
|
+
return new GradiumVoiceProvider({
|
|
12
|
+
apiKey: secrets.apiKey,
|
|
13
|
+
defaultVoiceId: config?.defaultVoiceId,
|
|
14
|
+
region: config?.region,
|
|
15
|
+
baseUrl: config?.baseUrl,
|
|
16
|
+
timeoutMs: config?.timeoutMs,
|
|
17
|
+
outputFormat: config?.outputFormat
|
|
18
|
+
});
|
|
19
|
+
case "ai-voice.fal":
|
|
20
|
+
return new FalVoiceProvider({
|
|
21
|
+
apiKey: secrets.apiKey,
|
|
22
|
+
modelId: config?.modelId,
|
|
23
|
+
defaultVoiceUrl: config?.defaultVoiceUrl,
|
|
24
|
+
defaultExaggeration: config?.defaultExaggeration,
|
|
25
|
+
defaultTemperature: config?.defaultTemperature,
|
|
26
|
+
defaultCfg: config?.defaultCfg,
|
|
27
|
+
pollIntervalMs: config?.pollIntervalMs
|
|
28
|
+
});
|
|
29
|
+
default:
|
|
30
|
+
throw new Error(`Unsupported voice provider: ${integrationKey}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// src/handlers/list-voices.ts
|
|
35
|
+
async function listVoices(input) {
|
|
36
|
+
const provider = createVoiceProvider(input);
|
|
37
|
+
return provider.listVoices();
|
|
38
|
+
}
|
|
39
|
+
export {
|
|
40
|
+
listVoices
|
|
41
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// src/handlers/create-provider.ts
|
|
2
|
+
import { FalVoiceProvider } from "@contractspec/integration.providers-impls/impls/fal-voice";
|
|
3
|
+
import { GradiumVoiceProvider } from "@contractspec/integration.providers-impls/impls/gradium-voice";
|
|
4
|
+
function createVoiceProvider(input) {
|
|
5
|
+
const { integrationKey, secrets, config } = input;
|
|
6
|
+
if (!secrets.apiKey) {
|
|
7
|
+
throw new Error("Voice provider apiKey is required.");
|
|
8
|
+
}
|
|
9
|
+
switch (integrationKey) {
|
|
10
|
+
case "ai-voice.gradium":
|
|
11
|
+
return new GradiumVoiceProvider({
|
|
12
|
+
apiKey: secrets.apiKey,
|
|
13
|
+
defaultVoiceId: config?.defaultVoiceId,
|
|
14
|
+
region: config?.region,
|
|
15
|
+
baseUrl: config?.baseUrl,
|
|
16
|
+
timeoutMs: config?.timeoutMs,
|
|
17
|
+
outputFormat: config?.outputFormat
|
|
18
|
+
});
|
|
19
|
+
case "ai-voice.fal":
|
|
20
|
+
return new FalVoiceProvider({
|
|
21
|
+
apiKey: secrets.apiKey,
|
|
22
|
+
modelId: config?.modelId,
|
|
23
|
+
defaultVoiceUrl: config?.defaultVoiceUrl,
|
|
24
|
+
defaultExaggeration: config?.defaultExaggeration,
|
|
25
|
+
defaultTemperature: config?.defaultTemperature,
|
|
26
|
+
defaultCfg: config?.defaultCfg,
|
|
27
|
+
pollIntervalMs: config?.pollIntervalMs
|
|
28
|
+
});
|
|
29
|
+
default:
|
|
30
|
+
throw new Error(`Unsupported voice provider: ${integrationKey}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// src/handlers/synthesize.ts
|
|
35
|
+
async function synthesizeVoice(input) {
|
|
36
|
+
const provider = createVoiceProvider(input);
|
|
37
|
+
return provider.synthesize(input.synthesis);
|
|
38
|
+
}
|
|
39
|
+
export {
|
|
40
|
+
synthesizeVoice
|
|
41
|
+
};
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
// src/connection.sample.ts
|
|
2
|
+
var gradiumVoiceConnection = {
|
|
3
|
+
meta: {
|
|
4
|
+
id: "conn-gradium-voice-demo",
|
|
5
|
+
tenantId: "acme-inc",
|
|
6
|
+
integrationKey: "ai-voice.gradium",
|
|
7
|
+
integrationVersion: "1.0.0",
|
|
8
|
+
label: "Gradium Voice",
|
|
9
|
+
environment: "production",
|
|
10
|
+
createdAt: "2026-01-01T00:00:00.000Z",
|
|
11
|
+
updatedAt: "2026-01-01T00:00:00.000Z"
|
|
12
|
+
},
|
|
13
|
+
ownershipMode: "byok",
|
|
14
|
+
config: {
|
|
15
|
+
defaultVoiceId: "YTpq7expH9539ERJ",
|
|
16
|
+
region: "eu",
|
|
17
|
+
outputFormat: "wav"
|
|
18
|
+
},
|
|
19
|
+
secretProvider: "vault",
|
|
20
|
+
secretRef: "vault://integrations/acme-inc/conn-gradium-voice-demo",
|
|
21
|
+
status: "connected"
|
|
22
|
+
};
|
|
23
|
+
var falVoiceConnection = {
|
|
24
|
+
meta: {
|
|
25
|
+
id: "conn-fal-voice-demo",
|
|
26
|
+
tenantId: "acme-inc",
|
|
27
|
+
integrationKey: "ai-voice.fal",
|
|
28
|
+
integrationVersion: "1.0.0",
|
|
29
|
+
label: "Fal Voice",
|
|
30
|
+
environment: "production",
|
|
31
|
+
createdAt: "2026-01-01T00:00:00.000Z",
|
|
32
|
+
updatedAt: "2026-01-01T00:00:00.000Z"
|
|
33
|
+
},
|
|
34
|
+
ownershipMode: "byok",
|
|
35
|
+
config: {
|
|
36
|
+
modelId: "fal-ai/chatterbox/text-to-speech",
|
|
37
|
+
defaultVoiceUrl: "https://storage.googleapis.com/chatterbox-demo-samples/prompts/male_rickmorty.mp3",
|
|
38
|
+
defaultExaggeration: 0.25,
|
|
39
|
+
defaultTemperature: 0.7,
|
|
40
|
+
defaultCfg: 0.5,
|
|
41
|
+
pollIntervalMs: 1000
|
|
42
|
+
},
|
|
43
|
+
secretProvider: "vault",
|
|
44
|
+
secretRef: "vault://integrations/acme-inc/conn-fal-voice-demo",
|
|
45
|
+
status: "connected"
|
|
46
|
+
};
|
|
47
|
+
var voiceSampleConnections = [
|
|
48
|
+
gradiumVoiceConnection,
|
|
49
|
+
falVoiceConnection
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
// src/docs/voice-providers.docblock.ts
|
|
53
|
+
import { registerDocBlocks } from "@contractspec/lib.contracts/docs";
|
|
54
|
+
var blocks = [
|
|
55
|
+
{
|
|
56
|
+
id: "docs.examples.voice-providers",
|
|
57
|
+
title: "Voice Providers (example)",
|
|
58
|
+
summary: "Multi-provider voice integration example covering Gradium and Fal text-to-speech flows.",
|
|
59
|
+
kind: "reference",
|
|
60
|
+
visibility: "public",
|
|
61
|
+
route: "/docs/examples/voice-providers",
|
|
62
|
+
tags: ["voice", "tts", "gradium", "fal", "example"],
|
|
63
|
+
body: `## What this example shows
|
|
64
|
+
` + "- Provider selection for `ai-voice.gradium` and `ai-voice.fal`.\n" + `- Listing voice catalogs and synthesizing text into audio bytes.
|
|
65
|
+
` + `- Connection metadata patterns for BYOK secret references.
|
|
66
|
+
|
|
67
|
+
` + `## Secrets and config
|
|
68
|
+
` + "- `apiKey` for each provider.\n" + "- Gradium config: `defaultVoiceId`, `region`, `outputFormat`.\n" + "- Fal config: `modelId`, `defaultVoiceUrl`, synthesis tuning fields.\n\n" + `## Guardrails
|
|
69
|
+
` + `- Keep API keys in secret providers only.
|
|
70
|
+
` + `- Prefer declarative provider config over hardcoded runtime options.
|
|
71
|
+
` + "- Keep synthesis side effects explicit for deterministic workflows."
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
id: "docs.examples.voice-providers.usage",
|
|
75
|
+
title: "Voice Providers - Usage",
|
|
76
|
+
summary: "How to wire provider factory and synthesis helpers in runtime code.",
|
|
77
|
+
kind: "usage",
|
|
78
|
+
visibility: "public",
|
|
79
|
+
route: "/docs/examples/voice-providers/usage",
|
|
80
|
+
tags: ["voice", "usage"],
|
|
81
|
+
body: `## Usage
|
|
82
|
+
` + "- Call `createVoiceProvider` with integration key, secrets, and config.\n" + "- Use `listVoices` to expose voice choices in admin/config screens.\n" + "- Use `synthesizeVoice` for message generation or workflow steps.\n\n" + `## Notes
|
|
83
|
+
` + `- Fal uses an audio URL output; this example downloads bytes for a canonical result shape.
|
|
84
|
+
` + "- Gradium maps provider output formats into ContractSpec voice result conventions."
|
|
85
|
+
}
|
|
86
|
+
];
|
|
87
|
+
registerDocBlocks(blocks);
|
|
88
|
+
// src/example.ts
|
|
89
|
+
import { defineExample } from "@contractspec/lib.contracts";
|
|
90
|
+
var example = defineExample({
|
|
91
|
+
meta: {
|
|
92
|
+
key: "voice-providers",
|
|
93
|
+
version: "1.0.0",
|
|
94
|
+
title: "Voice Providers (Gradium and Fal)",
|
|
95
|
+
description: "Multi-provider voice integration example for Gradium and Fal text-to-speech adapters.",
|
|
96
|
+
kind: "integration",
|
|
97
|
+
visibility: "public",
|
|
98
|
+
stability: "experimental",
|
|
99
|
+
owners: ["@platform.integrations"],
|
|
100
|
+
tags: ["voice", "tts", "gradium", "fal", "integrations"]
|
|
101
|
+
},
|
|
102
|
+
docs: {
|
|
103
|
+
rootDocId: "docs.examples.voice-providers",
|
|
104
|
+
usageDocId: "docs.examples.voice-providers.usage"
|
|
105
|
+
},
|
|
106
|
+
entrypoints: {
|
|
107
|
+
packageName: "@contractspec/example.voice-providers",
|
|
108
|
+
docs: "./docs"
|
|
109
|
+
},
|
|
110
|
+
surfaces: {
|
|
111
|
+
templates: true,
|
|
112
|
+
sandbox: { enabled: true, modes: ["markdown", "specs"] },
|
|
113
|
+
studio: { enabled: true, installable: true },
|
|
114
|
+
mcp: { enabled: true }
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
var example_default = example;
|
|
118
|
+
|
|
119
|
+
// src/handlers/create-provider.ts
|
|
120
|
+
import { FalVoiceProvider } from "@contractspec/integration.providers-impls/impls/fal-voice";
|
|
121
|
+
import { GradiumVoiceProvider } from "@contractspec/integration.providers-impls/impls/gradium-voice";
|
|
122
|
+
function createVoiceProvider(input) {
|
|
123
|
+
const { integrationKey, secrets, config } = input;
|
|
124
|
+
if (!secrets.apiKey) {
|
|
125
|
+
throw new Error("Voice provider apiKey is required.");
|
|
126
|
+
}
|
|
127
|
+
switch (integrationKey) {
|
|
128
|
+
case "ai-voice.gradium":
|
|
129
|
+
return new GradiumVoiceProvider({
|
|
130
|
+
apiKey: secrets.apiKey,
|
|
131
|
+
defaultVoiceId: config?.defaultVoiceId,
|
|
132
|
+
region: config?.region,
|
|
133
|
+
baseUrl: config?.baseUrl,
|
|
134
|
+
timeoutMs: config?.timeoutMs,
|
|
135
|
+
outputFormat: config?.outputFormat
|
|
136
|
+
});
|
|
137
|
+
case "ai-voice.fal":
|
|
138
|
+
return new FalVoiceProvider({
|
|
139
|
+
apiKey: secrets.apiKey,
|
|
140
|
+
modelId: config?.modelId,
|
|
141
|
+
defaultVoiceUrl: config?.defaultVoiceUrl,
|
|
142
|
+
defaultExaggeration: config?.defaultExaggeration,
|
|
143
|
+
defaultTemperature: config?.defaultTemperature,
|
|
144
|
+
defaultCfg: config?.defaultCfg,
|
|
145
|
+
pollIntervalMs: config?.pollIntervalMs
|
|
146
|
+
});
|
|
147
|
+
default:
|
|
148
|
+
throw new Error(`Unsupported voice provider: ${integrationKey}`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// src/handlers/list-voices.ts
|
|
153
|
+
async function listVoices(input) {
|
|
154
|
+
const provider = createVoiceProvider(input);
|
|
155
|
+
return provider.listVoices();
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// src/handlers/synthesize.ts
|
|
159
|
+
async function synthesizeVoice(input) {
|
|
160
|
+
const provider = createVoiceProvider(input);
|
|
161
|
+
return provider.synthesize(input.synthesis);
|
|
162
|
+
}
|
|
163
|
+
export {
|
|
164
|
+
voiceSampleConnections,
|
|
165
|
+
synthesizeVoice,
|
|
166
|
+
listVoices,
|
|
167
|
+
gradiumVoiceConnection,
|
|
168
|
+
falVoiceConnection,
|
|
169
|
+
example_default as example,
|
|
170
|
+
createVoiceProvider
|
|
171
|
+
};
|