openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
5 lines • 1.89 kB
JavaScript
import{c as normalizeOptionalLowercaseString,l as normalizeOptionalString}from"./string-coerce-CpTFcSwY.mjs";import{c as asFiniteNumberInRange,w as parseStrictFiniteNumber}from"./number-coercion-B3CfI447.mjs";import{rmSync}from"node:fs";
//!src/tts/tts-provider-helpers.ts
const TEMP_FILE_CLEANUP_DELAY_MS=3e5;function resolveSpeechProviderApiKey(...e){for(const t of e){const e=normalizeOptionalString(t);if(e)return e}}function requireInRange(e,t,n,r){if(!Number.isFinite(e)||e<t||e>n)throw new Error(`${r} must be between ${t} and ${n}`)}function normalizeLanguageCode(e){const t=normalizeOptionalLowercaseString(e);if(!t)return;if(!/^[a-z]{2}$/.test(t))throw new Error(`languageCode must be a 2-letter ISO 639-1 code (e.g. en, de, fr)`);return t}function normalizeApplyTextNormalization(e){const t=normalizeOptionalLowercaseString(e);if(!t)return;if(t===`auto`||t===`on`||t===`off`)return t;throw new Error(`applyTextNormalization must be one of: auto, on, off`)}function normalizeSeed(e){if(e==null)return;const t=Math.floor(e);if(!Number.isFinite(t)||t<0||t>4294967295)throw new Error(`seed must be between 0 and 4294967295`);return t}function scheduleCleanup(e,t=TEMP_FILE_CLEANUP_DELAY_MS){setTimeout(()=>{try{rmSync(e,{recursive:true,force:true})}catch{}},t).unref()}
//!src/tts/directive-number.ts
function parseSpeechDirectiveNumberOverride(e){if(!e.ctx.policy.allowVoiceSettings)return{handled:true};const t=parseStrictFiniteNumber(e.ctx.value);if(t===void 0||asFiniteNumberInRange(t,e.range)===void 0)return{handled:true,warnings:[e.warning(e.ctx.value)]};const n={[e.overrideKey]:t};return{handled:true,overrides:e.mergeCurrentOverrides?{...e.ctx.currentOverrides,...n}:n}}export{requireInRange as a,normalizeSeed as i,normalizeApplyTextNormalization as n,resolveSpeechProviderApiKey as o,normalizeLanguageCode as r,scheduleCleanup as s,parseSpeechDirectiveNumberOverride as t};