@openclaw/gradium-speech 2026.7.2-beta.7 → 2026.8.1-beta.2

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.
@@ -2,11 +2,12 @@ import { GRADIUM_VOICES, normalizeGradiumBaseUrl } from "./shared.js";
2
2
  import { gradiumTTS } from "./tts.js";
3
3
  import { resolveGeneratedMediaMaxBytes } from "openclaw/plugin-sdk/media-generation-runtime";
4
4
  import { normalizeResolvedSecretInputString } from "openclaw/plugin-sdk/secret-input";
5
- import { asObject, trimToUndefined } from "openclaw/plugin-sdk/speech";
5
+ import { trimToUndefined } from "openclaw/plugin-sdk/speech";
6
6
  import { resolveSpeechProviderApiKey } from "openclaw/plugin-sdk/speech-core";
7
+ import { asOptionalRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
7
8
  //#region extensions/gradium/speech-provider.ts
8
9
  function normalizeGradiumProviderConfig(rawConfig) {
9
- const raw = asObject(asObject(rawConfig.providers)?.gradium) ?? asObject(rawConfig.gradium);
10
+ const raw = asOptionalRecord(asOptionalRecord(rawConfig.providers)?.gradium) ?? asOptionalRecord(rawConfig.gradium);
10
11
  return {
11
12
  apiKey: normalizeResolvedSecretInputString({
12
13
  value: raw?.apiKey,
@@ -27,6 +28,20 @@ function readGradiumProviderConfig(config) {
27
28
  function resolveGradiumApiKey(configApiKey) {
28
29
  return resolveSpeechProviderApiKey(trimToUndefined(configApiKey), process.env.GRADIUM_API_KEY);
29
30
  }
31
+ async function synthesizeGradium(req, outputFormat) {
32
+ const config = readGradiumProviderConfig(req.providerConfig);
33
+ const apiKey = resolveGradiumApiKey(config.apiKey);
34
+ if (!apiKey) throw new Error("Gradium API key missing");
35
+ return await gradiumTTS({
36
+ text: req.text,
37
+ apiKey,
38
+ baseUrl: config.baseUrl,
39
+ voiceId: trimToUndefined(req.providerOverrides?.voiceId) ?? config.voiceId,
40
+ outputFormat,
41
+ timeoutMs: req.timeoutMs,
42
+ maxBytes: resolveGeneratedMediaMaxBytes(req.cfg, "audio")
43
+ });
44
+ }
30
45
  function isGradiumProviderConfigured(config) {
31
46
  if (!resolveGradiumApiKey(config.apiKey)) return false;
32
47
  try {
@@ -68,43 +83,19 @@ function buildGradiumSpeechProvider() {
68
83
  })),
69
84
  isConfigured: ({ providerConfig }) => isGradiumProviderConfigured(providerConfig),
70
85
  synthesize: async (req) => {
71
- const config = readGradiumProviderConfig(req.providerConfig);
72
- const overrides = req.providerOverrides ?? {};
73
- const apiKey = resolveGradiumApiKey(config.apiKey);
74
- if (!apiKey) throw new Error("Gradium API key missing");
75
86
  const wantsVoiceNote = req.target === "voice-note";
76
87
  const outputFormat = wantsVoiceNote ? "opus" : "wav";
77
88
  return {
78
- audioBuffer: await gradiumTTS({
79
- text: req.text,
80
- apiKey,
81
- baseUrl: config.baseUrl,
82
- voiceId: trimToUndefined(overrides.voiceId) ?? config.voiceId,
83
- outputFormat,
84
- timeoutMs: req.timeoutMs,
85
- maxBytes: resolveGeneratedMediaMaxBytes(req.cfg, "audio")
86
- }),
89
+ audioBuffer: await synthesizeGradium(req, outputFormat),
87
90
  outputFormat,
88
91
  fileExtension: wantsVoiceNote ? ".opus" : ".wav",
89
92
  voiceCompatible: wantsVoiceNote
90
93
  };
91
94
  },
92
95
  synthesizeTelephony: async (req) => {
93
- const config = readGradiumProviderConfig(req.providerConfig);
94
- const overrides = req.providerOverrides ?? {};
95
- const apiKey = resolveGradiumApiKey(config.apiKey);
96
- if (!apiKey) throw new Error("Gradium API key missing");
97
96
  const outputFormat = "ulaw_8000";
98
97
  return {
99
- audioBuffer: await gradiumTTS({
100
- text: req.text,
101
- apiKey,
102
- baseUrl: config.baseUrl,
103
- voiceId: trimToUndefined(overrides.voiceId) ?? config.voiceId,
104
- outputFormat,
105
- timeoutMs: req.timeoutMs,
106
- maxBytes: resolveGeneratedMediaMaxBytes(req.cfg, "audio")
107
- }),
98
+ audioBuffer: await synthesizeGradium(req, outputFormat),
108
99
  outputFormat,
109
100
  sampleRate: 8e3
110
101
  };
package/dist/tts.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { GRADIUM_API_HOSTNAME, normalizeGradiumBaseUrl } from "./shared.js";
2
- import { assertOkOrThrowProviderError } from "openclaw/plugin-sdk/provider-http";
3
- import { readResponseWithLimit } from "openclaw/plugin-sdk/response-limit-runtime";
2
+ import { assertOkOrThrowProviderError, readProviderBinaryResponse } from "openclaw/plugin-sdk/provider-http";
4
3
  import { fetchWithSsrFGuard } from "openclaw/plugin-sdk/ssrf-runtime";
5
4
  //#region extensions/gradium/tts.ts
6
5
  const DEFAULT_TTS_MAX_BYTES = 16 * 1024 * 1024;
@@ -29,7 +28,10 @@ async function gradiumTTS(params) {
29
28
  });
30
29
  try {
31
30
  await assertOkOrThrowProviderError(response, "Gradium API error");
32
- return await readResponseWithLimit(response, maxBytes, { onOverflow: ({ maxBytes: maxBytesLocal }) => /* @__PURE__ */ new Error(`Gradium TTS audio response exceeds ${maxBytesLocal} bytes`) });
31
+ return Buffer.from(await readProviderBinaryResponse(response, "Gradium API error", "audio", {
32
+ maxBytes,
33
+ onOverflow: ({ maxBytes: maxBytesLocal }) => /* @__PURE__ */ new Error(`Gradium TTS audio response exceeds ${maxBytesLocal} bytes`)
34
+ }));
33
35
  } finally {
34
36
  await release();
35
37
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/gradium-speech",
3
- "version": "2026.7.2-beta.7",
3
+ "version": "2026.8.1-beta.2",
4
4
  "description": "OpenClaw Gradium speech plugin.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -18,10 +18,10 @@
18
18
  "minHostVersion": ">=2026.6.8"
19
19
  },
20
20
  "compat": {
21
- "pluginApi": ">=2026.7.2-beta.7"
21
+ "pluginApi": ">=2026.8.1-beta.2"
22
22
  },
23
23
  "build": {
24
- "openclawVersion": "2026.7.2-beta.7",
24
+ "openclawVersion": "2026.8.1-beta.2",
25
25
  "bundledDist": false
26
26
  },
27
27
  "release": {
@@ -38,7 +38,7 @@
38
38
  "README.md"
39
39
  ],
40
40
  "peerDependencies": {
41
- "openclaw": ">=2026.7.2-beta.7"
41
+ "openclaw": ">=2026.8.1-beta.2"
42
42
  },
43
43
  "peerDependenciesMeta": {
44
44
  "openclaw": {